Is there any custom php code that lets me overwrite next_post_link
so I can customize it to my liking? I can add code in functions.php
Right now it shows next post But I want to show something else
Is there any custom php code that lets me overwrite next_post_link
so I can customize it to my liking? I can add code in functions.php
Right now it shows next post But I want to show something else
You can't easily change only the URL of that link, because there is no filter that will allow you to do that, but...
next_post_link
uses get_next_post_link
. There are no filters in any of these functions, but... get_next_post_link
uses get_adjacent_post_link
and inside of that function you can see {$adjacent}_post_link
hook.
So now we can check docs for that hook. And then write some code:
function my_next_post_link($output, $format, $link, $post, $adjacent) {
return '<a href="<MY LINK">MY LINK LABEL</a>';
}
add_filter( 'next_post_link', 'my_next_post_link', 10, 5 );
PS. Most likely you also have to add some conditions in there, so you don't change every link on your site and only the one you want to.