我在我的帖子内容周围加了一个短代码,我注意到它使归档页面上的摘录变为空白,而不是从\\u内容/帖子自动生成一个。不知是什么原因造成的,也不知该怎么办。它甚至没有在the_excerpt
它只是一片空白。我会想,如果有问题的话,应该是出现在the_excerpt
但这只是一个空白的句号。我预定义的所有短代码所做的就是围绕内容包装一些复杂的HTML5标记,在某些情况下,为了保持一致性,作者会经常出错,因此它不是一个复杂的短代码。我的帖子输出完美the_content
. 一旦我删除了短代码,它就会再次工作。如果我把短代码放回去,并设置一个手动摘录,它就会工作,所以只有当它必须自动生成the_excerpt
来自一篇用这个短代码包装的帖子。如果其他人有过类似的经历,我很难解释或解决,请欣赏任何想法。
非常感谢。
在简单/精简的术语中,im包装例如:
add_shortcode( \'ARTICLE_SECTION\', \'trg_shortcode_article_section\');
function trg_shortcode_article_section_run( $content ) {
global $shortcode_tags;
// Backup current registered shortcodes and clear them all out
$orig_shortcode_tags = $shortcode_tags;
remove_all_shortcodes();
add_shortcode( \'ARTICLE_SECTION\', \'trg_shortcode_article_section\' );
// Do the shortcode (only the one above is registered)
$content = do_shortcode( $content );
// Put the original shortcodes back
$shortcode_tags = $orig_shortcode_tags;
return $content;
}
// actual shortcode function
function trg_shortcode_article_section( $atts, $content = null ) {
$atts = array();
$output = \'<section>\';
$output .= $content . \'</section>\';
return $output;
}
add_filter( \'the_content\', \'trg_shortcode_article_section_run\', 7 );
在部分循环中:<p><?=trg_excerpt_article()?></p>
我一开始就投入了调试工作,而不是做其他事情,只是:function trg_excerpt_article(){
echo \'<!-- excerpt - \' . get_the_excerpt() . \' -->\';
}
这也会返回空白。