是的,这是可能的,通过filters
.
/**
* Functon creates default content for pagination function previous_post_link() and next_post_link()
* @param $original string HTML content returned by previous_post_link/next_post_link to be modified
* @return string
*/
function default_prev_next_link($original) {
//if prev/next link does not exists, $original is empty string
if(!$original)
return "<a href='#'>new content</a>";
//you need to return original value, in case it is set
return $original;
}
//hook our function to filters
add_filter('previous_post_link', 'default_prev_next_link');
add_filter('next_post_link', 'default_prev_next_link');
最终,您可以创建两个单独的函数,分别连接到 *_post 链接