从一个示例开始更有意义,下面是一个示例函数:
function seo_meta_tags() {
global $post;
if( is_singular() ) {
setup_postdata( $post );
$description = str_replace( \'... <a class="read-more" href="\' . get_permalink() . \'">Cont. reading →</a>\', \'...\', get_the_excerpt() );
wp_reset_postdata();
echo \'<meta itemprop="description" name="description" content="\' . $description . \'">\';
}
}
NOTE: 代码只是给你一个想法,告诉你我想要完成什么,而不是我到底是怎么做的现在说到重点,应该setup_postdata( $post )
使用关闭wp_reset_postdata()
如示例所示?