我有一个插件,为课程定制了帖子类型。我想自定义存档页帖子中的内容and style it. 我意识到存档页正在使用the_content()
检索帖子的内容,我可以使用相应的过滤器对其进行自定义;然而,它剥离了HTML,不允许我对其进行样式设置。我该如何度过这一关?
function eri_course_archive_content_filter($content) {
if (is_post_type_archive( \'eri-courses\' )) {
$content = (strlen($content) <= 140)? $content : wp_html_excerpt($content, 140);
$extra = \'<div class="x-text">
<ul class="x-ul-icons" style="padding-left: 1%;">
<li class="x-li-icon" style="padding-bottom: 1%;"><i class="x-icon-o-dollar-sign" aria-hidden="true" style="color: #47c3d3;" data-x-icon-o=""></i><strong>Cost:</strong> \'.get_post_meta( get_the_ID() , \'_post_cost\', true ).\'</li>
<li class="x-li-icon" style="padding-bottom: 1%;"><i class="x-icon-o-clock" aria-hidden="true" style="color: #47c3d3;" data-x-icon-o=""></i><strong>Time:</strong> \'.get_post_meta( get_the_ID() , \'_post_time\', true ).\'</li>
</ul>
</div>\';
return $content . $extra;
} else {
return $content;
}
}
add_filter(\'the_content\', \'eri_course_archive_content_filter\');