For some reason a title
attribute is not appended to next_post_link
and prev_post_link
calls in WordPress. How can I add one?
Leave a Reply
You must be logged in to post a comment.
For some reason a title
attribute is not appended to next_post_link
and prev_post_link
calls in WordPress. How can I add one?
You must be logged in to post a comment.
Update
As I deleted the Repo on GitHub, here’s a new answer.
No need for functions and filters all you need to do is to use
get_adjacent_post
instead ofnext_post_link
andprev_post_link
, Note thatget_adjacent_post
is used to get previous and next post, you can read about it hereTo get previous post and it’s title attribute use this
To get next post and it’s title attribute use this
I’m trying to do this right now as well. The filter function seems like the best bet.
This is where I’m at now, but I can’t seem to get the title of the next or previous post and pass it to the filter.
Edit: Figured it out. A bit hackey probably, but it works.
A bit old perhaps, and I wasn’t really sure on how to make a comment on a reply…
In short, after looking for the same solution I’ve modified Picard102’s suggestion just a tiny bit:
Shortened the code a little.