previous_post_link
和next_post_link
两者都直接输出链接,这在您的情况下不起作用,因为您试图将结果分配给变量。使用get_previous_post_link()
和get_next_post_link()
相反-
function add_pagin( $content ) {
if ( is_singular(\'post\') ) {
$content .= get_previous_post_link() . get_next_post_link();
}
return $content;
}
add_filter( \'the_content\', \'add_pagin\' );