Archived topic
Volume: Custom Post Navigation not behaving as expected
5 replies · Started by Tim on April 8, 2020
Hello
I'm finding that the Custom Post Navigation hook is not behaving as expected.
I would presume that each time this navigation is displayed, it should show the previous/next post by date.
But in the cited URL there is no next post displayed, even though there IS a later post of the same category.
Incidentally the anticipated later post also does not display the previous post.
What could be awry here ?
Hi there.
can you try rebuilding permalinks ?
Go to Settings > Permalinks and hit save a couple of times.
Note: ( if i remember correctly ) the Post Nav is not limited to the current post category....
Hi David
I did try that a few times, and clearing browser cache, but no joy.
Yes it was another question I was going to ask: "how to limit to current post category ?".
The Nav is added using a Hook element in Appearance > Elements --> Custom Post Navigation.
Within the code you'll see two lines:
$prevPost = get_previous_post(false); & $nextPost = get_next_post(false);
swap false for true and the posts displayed will be in the same category.
Can't explain why that post is not displayed the nav - try creating a new post to see if that works.
OK that's great and once I set them to true the problem post was finally displayed in the custom nav.
Glad to hear that