Hi @ehuds
Please see the documentation: https://docs.pods.io/displaying-pods/pods-shortcode/
You’ll need the where param for this, see examples below on the page.
Cheers, Jory
Thread Starter
ehuds
(@ehuds)
Hey Again,
Thank you for your time and respond. But… 🙂 I did saw that page and need some help setting the short code. Maybe you can help? or anyone.
custom post type: yacht
custom category: yacht_category
I want to display a list of yachts (only title) from the same category in the single yacht template.
This is what I have so far:
[pods name=”yacht” where=”yacht_category.slug = ‘{@Same_Category_as_this_post}'”][/pods]
I’m not sure if the where is correct and what to put in the magic tag.
Any help?
Thanks
Hi @ehuds
You’re already almost there!
Since you filter by category slug you need to set that in the magic tag: {@category_name.slug} (not the .slug in the end).
Cheers, Jory
Thread Starter
ehuds
(@ehuds)
Hey,
Thank you for your time and help but I’m not exactly sure how to create the short code.
I’m not sure I explained myself correctly, let me try again.
I want to list all custom post from the same category the current post is.
The short code I posted with the slug was just an example. If there is a different way to achieve what I want that’s fine.
Can you or someone help me and post a complete code that will do that?
Thank you very much
Hi @ehuds
Did you try my suggestions?
The magic tag {@category} will refer to the category of the referenced object where you use the shortcode.
So basically, if you use the shortcode in the post pod template then the magic tags will reference to the current post.
Note that you do need to use it in a Pod Template otherwise the magic tags won’t be parsed!
This is mentioned in the beginning of this doc: https://docs.pods.io/displaying-pods/pods-shortcode/
In short:
– Create Pod template where you add the shortcode. Make sure you use the correct category (taxonomy) name. Note that the magic tags will not refer to the category but the post of the template!
– Put the new template in Elementor: [pods use_current=1 template="New template name"]
Please also make sure you view our videos to get a better understanding of Pods and more complex structures.
https://docs.pods.io/videos/grow-beyond-posts-pages-introduction-pods-framework/
Cheers, Jory
Thread Starter
ehuds
(@ehuds)
Hey again,
Thank you but I couldn’t figure it out. I will try to explain better maybe someone can help:
I want to display a list of yachts names (the post title) that are from the same category.
custom post name: yacht
custom taxonomy: yacht_category
this is what I want but I’m not sure how to write it:
list all yachts where the category = current category
can someone give me the code? please don’t send me to more tutorials, I tried those.
Thanks
Hi @ehuds
The links I’ve send you are not tutorials but documentation pages. These explain how the code works so you can learn more about Pods and WordPress and implement it yourself.
Simply providing code never actually helps and often results in more confusion.
In this actual case it simply cannot be done with a single piece of code, therefore I’ve send you the steps you need to take to create such a view:
Basically you need 2 templates, one for the yacht loop and one for the current post so you can pull the related yacht category.
Template 1 (yacht loop), something like:
- {@title}<br>
Template 2 (related yacht list):
[pods name="yacht" template="TEMPLATE 1 NAME" where=”yacht_category.slug = '{@yacht_category}'"]
Shortcode to use in Elementor:
[pods use_current=1 template="TEMPLATE 2 NAME"]
Note that the template names and actual field names need to be changed to the correct ones if you use different names than in this example.
If you need actual coding help it’s best to ask on more public locations than this support forum. We also have our own Slack channel with many community members helping each other: https://support.pods.io/chat/
Cheers, Jory
Thread Starter
ehuds
(@ehuds)
Thanks for your help but it didn’t work. I just see the pods code on the front end.
I will try the support chat.
Hi @ehuds
Ah check, in that case the Elementor module you’ve selected doesn’t parse shortcodes.
Please choose an Elementor module that supports shortcodes.
Cheers, Jory