我当前正在添加
add_filter(\'the_excerpt\', array($wp_embed, \'autoembed\'), 9);
给我的functions.php
如果没有任何其他建议,那就太好了。如果我添加$content-width
至功能。php忽略设置。我有wp-debug
打开,没有错误/警告,也没有记录错误。我当前正在添加
add_filter(\'the_excerpt\', array($wp_embed, \'autoembed\'), 9);
给我的functions.php
如果没有任何其他建议,那就太好了。如果我添加$content-width
至功能。php忽略设置。我有wp-debug
打开,没有错误/警告,也没有记录错误。我对你的主题没有更多的了解,只能进行一些猜测。您作为摘录输入了什么,您当前看到的摘录输出是什么,预期输出是什么?您是否看到该URL显示在摘录中,还是正在删除?
$wp_embed
?global $wp_embed;
add_filter( \'the_excerpt\', array( $wp_embed, \'autoembed\' ), 9 );
您是否使用短代码?由于一些冲突和处理所需的顺序[embed]
短代码有some hacks 让事情正常运转。您可能需要模仿相同的方法才能使其用于摘录。
// untested code: it may not be this simple, I haven\'t done it before
global $wp_embed
add_filter( \'the_excerpt\', array( $wp_embed, \'run_shortcode\' ), 9 );
add_shortcode( \'embed\', \'__return_false\', 9 );
add_filter( \'the_excerpt\', array( $wp_embed, \'autoembed\' ), 9 );
您的模板是否使用the_excerpt()
还是依靠the_content()
, 还是使用get_the_excerpt()
?这些都是在不同阶段执行不同操作的不同功能,可能需要修改处理。
global $wp_embed;
add_filter( \'get_the_excerpt\', array( $wp_embed, \'autoembed\' ), 9 );
如果不知道更多信息,我只能建议您键入的内容可能有误,或者您的嵌入不大于您使用的设置,因此不会缩小。// use an underscore(_), not a hyphen(-)
// like this
$content_width = 600;
// not this
$content-width = 600;
我正在尝试构建一个主题,我想通过在函数中执行类似操作来控制帖子摘录的长度。php:function theme_excerpt_length( $length ) { return 45; } add_filter( \'excerpt_length\', \'theme_excerpt_length\', 999 ); 但它似乎没有达到将摘录长度减少到45个单词的预期效果。即使没有这个功能,有些摘录也比默认的55个单词长。怎么了?