Let’s say that I have a post that I only want to be shown in the page of the category that it belongs to. The problem is that this post is also visible in the latest posts page.
Is there a way to hide this post from the latest post page and show it only in the page of the category of the post?
Source:
pre_get_posts
Since you’re using the core “Page for Posts” settings, you should be able to use the awesome
pre_get_posts
action to remove the specific ID you want to exclude.This should work in your
functions.php
file or/mu-plugins/
plugin:Replace “{your post id}” with the ID of the post you want to exclude. It’s an
array
, so you can enter multiple IDs separated by commas if desired.If the post ID changes, then you’d need to setup some kind of option using the Settings API to store the ID you want to exclude.
Your question is hard to understand.. Do you mean a specific post or somthing automatic? if you mean a specific post and If you are using wp_query / query posts to loop for recent posts you can add this parameter.
Example query:
Hope this helps ;