编辑Wordpress Previous_post命令


Edit Wordpress Previous_post command

我使用下面的代码在wordpress上创建上一个和下一个按钮。

<?php previous_post('&laquo;  %', '', 'yes'); ?>

当前输出

<a href="http://domain.com/?p=6">Name</a> 

我如何编辑它使它输出

<a href="http://domain.com/single.php?p=6">Name</a> 

previous_post现在已弃用,您应该使用previous_post_link代替,然后添加一个过滤函数来更改URL:

function rewrite_previous_post_url($txt) {
    return preg_replace('#'?p='d+#','single.php$0',$txt);
}
add_filter('previous_post_link','rewrite_previous_post_url');