我正在使用以下代码,希望删除HTML的所有元素。
<?php $exerpttext = substr(get_post_field(\'post_content\', $post->ID), 0, 300);
if (!empty($exerpttext)) { echo $exerpttext.\'....\'; } ?>
我正在使用以下代码,希望删除HTML的所有元素。
<?php $exerpttext = substr(get_post_field(\'post_content\', $post->ID), 0, 300);
if (!empty($exerpttext)) { echo $exerpttext.\'....\'; } ?>
乍一看,这似乎是一个XY问题。
如果您只是想增加从帖子内容自动生成的摘录的长度,可以使用excerpt_length hook 在函数中。php。
function modify_excerpt_length( $length ) {
return 300;
}
add_filter( \'excerpt_length\', \'modify_excerpt_length\', 99 );
然后只需调用模板中的摘录:the_excerpt()
这将自动删除所有标记。我想获取所有自定义字段hidden 不存在。这不起作用:$postsForSitemap = get_posts(array( \'numberposts\' => -1, \'orderby\' => \'modified\', \'post_type\' => array(\'post\', \'page\'), \'order\' => \'DESC\', \'meta_key\' =&g