previous_post_link()
and next_post_link()
should work inside the the_content
filter.
There is nothing wrong with your code except you must return the value inside the filter instead of print. Otherwise I believe post link should be there at the beginning of content.
previous_post_link()
and next_post_link()
print the output so consider using get_previous_post_link()
and get_next_post_link()
.
function prevnext( $content ) {
$content .= '<div>' . get_previous_post_link() . '-' . get_next_post_link() . '</div>';
return $content;
}
add_action( 'the_content', 'prevnext', 4 );