-
hws991215
Please check the screenshot. I will also inform you of the rights of the rights holder.
-
Hi there,
it will require some PHP.
Try adding this PHP snippet to your site:function exclude_single_posts_archive($query) { if ( !is_admin() && !is_single() && $query->is_main_query() ) { $query->set('post__not_in', array( 123 ) ); } } add_action('pre_get_posts', 'exclude_single_posts_archive');This doc explains how to add PHP:
https://docs.generatepress.com/article/adding-php/the
123change to the ID of the post you want to exclude. -
hws991215
Where can I see the post ID? Please let me know with a screenshot.
-
Fernando
Here’s a URL with screenshots showing how to get the Post Id: https://kinsta.com/blog/wordpress-get-post-id/#1-find-the-id-within-each-posts-url
-
hws991215
thank you. There are multiple post IDs that I want to make invisible. Do I have to keep adding that code separately? If the IDs are 123, 456, and 789, can I add 123, 456, and 789 to the code?
-
Fernando
You can have it in one code as such:
function exclude_single_posts_archive($query) { if ( !is_admin() && !is_single() && $query->is_main_query() ) { $query->set('post__not_in', array( 123, 456, 789 ) ); } } add_action('pre_get_posts', 'exclude_single_posts_archive'); -
hws991215
.gb-query-loop-item.post-400.post { display:none; }Can I remove this existing code?
But if I delete this code, it appears on my site again. -
Fernando
The code provided by David removes the Posts from default archive pages.
For Query Loop Blocks, you can add and Exclude Post Parameter. Example: https://share.getcloudapp.com/NQup2dNJ
-
hws991215
Oh, thank you. I solved it.
-
Fernando
You’re welcome, Hws!
- You must be logged in to reply to this topic.