Archived topic
Hide posts that belong to a certain category from the post navigation links
2 replies · Started by George on February 23, 2021
Viewing posts 1–3 of 3
I am currently hiding posts that belong to a certain category from the blog page by using the following code:
add_filter('pre_get_posts', 'excludeCat');
function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-45');
}
return $query;
}
Is there a way to add to the query to also hide the posts from the post navigation links so that they don't get displayed either?
I think I found the solution in Tom's post here:
https://generatepress.com/forums/topic/post-navigation-how-exclude-a-category-from-next-and-previous-post-links/#post-481862
Glad to hear :)
This archived topic is closed to new replies.