Hello,
I’m trying to create an area at the bottom of my single post layout that queries posts similar to the one being viewed based on tags. A sort of “you could also be interested in” section. Could you help me out please?
Best,
Robert
Hello,
I’m trying to create an area at the bottom of my single post layout that queries posts similar to the one being viewed based on tags. A sort of “you could also be interested in” section. Could you help me out please?
Best,
Robert
Hello Robert,
Thanks for writing to us.
To get a similar post I would suggest you please set the Looper provider as a query string and you need to add this query string.
tag__in={{dc:term:slug}}&post_type=post&posts_per_page=3&offset=0&ignore_sticky_posts=1&post__not_in%5B0%5D={{dc:post:id}}
In case you have not seen the Looper doc please have a look at this to learn more about how to get similar posts.
Hope it helps
Thanks
Hello,
Thank you for your answer. I’ve inserted the string you suggested in the query looper but it doesn’t seem to work. The looper is not pulling any posts.
Thanks,
Robert
Thank you for the update. We may need to access the site to check this further. Please provide the login details in the secure note. Did you create a Looper Consumer?
Best regards.
Yes, there is a looper consumer in place. I’ve updated the post above with the login details and the link to a single post page.
We adjusted the query string in the Looper Provider.
{{ fn('get_terms', {taxonomy: 'post_tag', object_ids: post.id, hide_empty: false})|map(t => 'tag__in[]=' ~ t.term_id)|join('&') }}&post_type=post&posts_per_page=3&offset=0&ignore_sticky_posts=1&post__not_in[0]={{ post.id }}
Let us know if you need more info.
This works! Thanks a lot!