Is there a way to create one view and include a filter by post type?
Essentially, I want to list the three newest posts in a post type separately for multiple post types.
I know I can do this by duplicating the view for each post type but that isn't very efficient especially if I want to change something about all of the views in the future.
I don't want all the post type lists in the same place so a nested view won't work.
Thank you for getting in touch. Will this be a search view ?
If you want your view to display the different post types together you can make use of the order option to sort your view by the post type. This way your view will list out the same post types together.
No this will be a simple list of the most recent three post titles for a CPT, so the view might be used to list three "properties" (CPT) on one page and three "cars" on another page.
Ok thank you, in this case simply just sorting the view by the post type will allow you to be able to group your posts of similar post types together in 1 view.
Actually, that won't work. Maybe I am not being clear.
I would like one view which can on one page list the newest three of CPT1 and on another page can list the newest three of CPT2. Sorting by post type won't achieve that. I know I can create the same view over and over for each CPT but if possible I want to avoid that because I may want to change all of the views in some way later.
What this filter is doing is checking the page id to see if it equal to 123 and then modifying the view query's post type attribute to the slug of the post type that I want this page to display.
Please let me know if this filter helps.
Thanks,
Shane