Home › Toolset Professional Support › [Resolved] Use Post ID's in Shortcode
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
This topic contains 6 replies, has 2 voices.
Last updated by Pete 1 month, 2 weeks ago.
Assigned support staff: Shane.
We have a View Specifically ste up to display custom post types in blog posts.
This where all the taxonomy filters are set by shortcode attribute so we use one View for multiple posts. Works great, this typical of a shortcode we'd use:
[wpv-view name="tour-posts" limit="6" wpvpets="pets-yes" wvpcollections="close-to-coast, dog-friendly" wpvarea="dorset"]
However on occasion wish to use the same View, layout and design for specific posts. It's the layout we need to keep.
Is there a way of use this shortcode but with post ID's? Something like...
[wpv-view name="tour-posts" "post-id=235 post-id+23 post-id+478 post-id+93"]
Worth an ask as I have searched and can find nothing I understand 🙂
English (English )
Thank you for getting in touch. Yes it is possible to use the Post Id to filter the view.
If you go to your view and Edit it, just add a query filter for the Post Id and set it to get the ids from a shortcode parameter. See Screenshot.
Please let me know if this helps.
Hope you are keeping well.
Hmmm not sure I have explained this right, looking at adding post id to the Taxonomy filter is asking for specific ID's.
What I'm looking for is, using our existing View, with the filter set, see attached.
To have the option to add using a shortcode post ids, these would change when we use the shortcode on different posts.
So this example: [wpv-view name="tour-posts" "post-id=235 post-id+23 post-id+478 post-id+93"]
Would be on one, and other would have completely different id's.
Is this possible and if so how do i add ID's to a shortcode?
If I understand correctly you essentially just want to add the ability to filter the view by the Post Id as well.
If such is the case then i've explained how you can achieve this in my previous post. All that is needed is to add the filter for the Post ID and set it to get the ids from a shortcode parameter.
Hmmm not getting this or I'm looking at this the wrong way.
If I go to add the Post ID filter to the View, it shows an error as we're not adding them at the View stage.
You will need to select the option that says "Posts with IDs set by the View shortcode attribute: "
This will allow you to set the attribute that you want to use to pass the ids in the view. In this case the default will be ids, so you will declare your view like this.
[wpv-view name="tour-posts" ids="1024, 2048"]
Please let me know if this is a bit clearer.
My issue is resolved now. Thank you!
Known issues and solutions
Frequently asked support questions
Support tickets archive
Get help from experienced contractors
Meet Toolset support team
Toolset Customer Support Policy
Need to tell us something about the quality of support
How to remove personal information from your database for support