【问题标题】:Filter &lt;!--nextpage--&gt; tag while filtering shortcode in WordPress在 WordPress 中过滤短代码时过滤 <!--nextpage--> 标签
【发布时间】:2012-03-10 15:54:44
【问题描述】:

我有一个函数可以用一些内容替换我的简码,例如

function output() {
$output = '<div>In page 1</div>';
$output .= '<!--nextpage-->';
$output = '<div>In page 2</div>';
echo output;
}

add_filter('the_content','output');

但是在网页上,nextpage标签并没有转换成Pagination

谁能帮忙?

【问题讨论】:

    标签: php wordpress pagination


    【解决方案1】:

    过滤器应该返回值,而不是回显它们。如果您只是回显它们,其他过滤器将没有机会处理这些值(过滤器通常链接在一起)。

    尝试改变

    echo output;
    

    return $output;
    

    过滤器函数通常也接受要过滤的当前值的参数,但在此测试中您可能不需要它。

    如果这不起作用,则可能是在调用过滤器之前完成了分页。如果是这种情况,您可能需要为 add_filter 的第三个 ($priority) 参数使用低于默认值 10 的值(请参阅 the codex)。

    【讨论】:

      猜你喜欢
      • 2012-07-04
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多