[Resolved] Related blogposts on product detailpage
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I'm trying to show related blogposts (based on tag) on a product detailpage where product name equals tag name.
I've set up blogposts with a custom tag that is the same as the product name.
Example:
On hidden link (product detail page), I want to show blogposts with tag 'acrylinject-r'.
How do you set up the view's query filter to achieve this?
Hello. Thank you for contacting the Toolset support.
On your product details template you should try to add a view and set it to query the content type (post type) you want to display the posts and then add a taxonomy filter for tags and select the option "Value set by the current page where this View is shown".
Your proposed solution requires both content types (blogposts and products) to use the same tag.
Is it possible to use the tag's slug (blogposts) and get it from the URL (products) for comparisson?
To clarify:
Blogpost has tag 'Acrylic R'. So, the slug for that tag is 'acrylic-r'.
The product URL is '/product/acrylic-r/'
Is it possible to get the second part from the URL as well?
I feel - since this is a permalink - we should be able to fetch a parameter from the URL.
Maybe something like wpv-tag-slug?
What posts you want to display, you want to display posts from default post type post or from the product post type?
As I understand - you want to display posts from default post type post that has the tag assigned as "acrylic-r"and you have a product with title that has "acrylic-r" - correct?
You should create a view by adding the view block to your single product details content template and set the view to query the default post type "post" add the things you want to display within the loop editor.
There are 2 small errors in the snippet you provided.
A syntax error on line 11 ("=>" should be "=")
Your passing an array to get_term_by() while it is expecting a string.