wordpress发布内容过滤器

wordpress发布内容过滤器,wordpress,filter,pagination,Wordpress,Filter,Pagination,我想要编写添加到我的帖子内容标签的函数,我编写此函数: <?php function output($content) { $output = $content.'<!--nextpage-->'.$content; return $output; } add_filter('the_content','output'); ?> 函数add标签,但当我显示帖子时,这个标签不起作用,它就像html注释,也许有什么解决方案 也许我不必使用内容而是wp\u inse

我想要编写添加到我的帖子内容
标签的函数,我编写此函数:

<?php
function output($content) {
$output = $content.'<!--nextpage-->'.$content;

return $output;
}

add_filter('the_content','output');

?>

函数add
标签,但当我显示帖子时,这个标签不起作用,它就像html注释,也许有什么解决方案


也许我不必使用
内容
而是
wp\u insert\u post\u data

文本到“页面”的转换发生在
设置\u postdata
中。但是当调用具有相同名称的模板标记,
the\u content
时,将执行您使用的钩子。这意味着你必须在循环开始之前改变内容。这可能有点棘手。我不知道有什么合适的钩子,但是你可以检查
setup\u postdata
的源代码,可能有一个。但是,在主题中,您可以访问
$posts
,因此,如果您将其放入模板中,它应该可以工作:

global $posts;
array_map( function( $apost ) {
    $apost->post_content = $apost->post_content.'<!--nextpage-->'.$apost->post_content;
    return $apost;
}, $posts );
global$posts;
数组映射(函数($APAST){
$apost->post_content=$apost->post_content.''.$apost->post_content;
返回$APAST;
}美元员额);
如果您没有PHP版本=>5.3,就不能使用匿名函数。在这种情况下,此版本将起作用:

global $posts;
function output( $apost ) {
    $apost->post_content = $apost->post_content.'<!--nextpage-->'.$apost->post_content;
    return $apost;
}
array_map( 'output', $posts );
global$posts;
函数输出($APAST){
$apost->post_content=$apost->post_content.''.$apost->post_content;
返回$APAST;
}
数组映射('output',$posts);

什么意思不起作用?它应该做什么?你是对的,那是一个HTML注释,所以它不会显示在你的浏览器中。另外,你的代码也很奇怪,基本上你是在复制你的文本,并用你的标记将两个完全相同的副本分开……它必须添加post-pogination,但是标记
像html注释一样被显示