Specific pages or exclude specific pages
-
Is there a way to display a grid of an arbitrary list of pages, or to exclude specific pages? I’m using:
[thumbnailgrid posts_per_page='9' post_type='page']
But I only want to display certain particular pages in the grid.
-
Yes, according to the codex, you can grab the page id’s. Try this & let me know if it works. Replace the numbers with the actual id’s of the pages that you would like to exclude.
post__not_in =”3,8″
An alternate option, and the one that I would prefer, would be to enable categories on pages and to use categories to display pages in the grid. Some themes enable this, or you could use a plugin to do this.
http://www.wpbeginner.com/plugins/how-to-add-categories-and-tags-for-wordpress-pages/
https://wordpress.org/plugins/post-tags-and-categories-for-pages/
https://wordpress.org/plugins/add-tags-and-category-to-page/Thanks for the reply Adrian. I am no longer on the project where I used your plugin. But I think what I did – in a pinch – was to get them to order by using post date.
Thanks.
Hi Adrian,
I have a similar problem in that my grid consists of all posts within a category, but I’d like to exclude one post. I took the above suggestion, plugged in the post ID, and tried some variations, but couldn’t get it to work.
Is there another code I should try?
Thanks!
Hi, you tried post__not_in. Make sure that you used the correct id for the post and that it is not a sticky post.
Other factors besides sticky post can interfere with the post query, like the theme or other plugins. If the category is used by your theme for something else, that could also be an issue.
Let me know if you think that either of the above is the issue because there is something that I can try in the plugin to override that.
I will investigate this further.
The safest bet is to create a new category or tag just for the grid. Call it thumbnail. I understand that this may not be convenient but it is the easy answer.
Hi Adrian,
Thanks for your swift response! I triple-checked the post ID, and it’s definitely not a sticky post. This is a brand-new WP still using the TwentyFifteen theme for now, so I don’t think that’s a factor, either. So I’m not sure what the problem could be.
As the categories and tags are in heavy use for the site & they’re very visible, I’d prefer not to have to make a new one.
Thanks so much for your assistance!
I will download the new theme and see if I can duplicate this.
So how would one use this to display specific pages (not posts) without adding another plugin? thanks.
Jeremy,
Pages are a post type. Assuming your theme has featured images enabled for pages, you would use post_type=”page” in the shortcode.
Gotcha, and how would i indicate specific page ids to display?
I think that you would have to use post__in with comma delimited id’s. I haven’t had a chance to test this yet so I thank you for pushing this back up to the top.
I know that you don’t want to use more plugins, but categories make this really easy. You can download a plugin that enables page categories if your theme doesn’t do this already.
I just tested this and neither post__in nor post__not_in work. I will release an update within the week.
Hello, I’ve updated the plugin. This should work now. Please let me know if there are any issues.
Hello Adrian,
What shortcode should i use to exclude a particular category?
Many thanks
The topic ‘Specific pages or exclude specific pages’ is closed to new replies.