• Resolved ashishonl

    (@ashishonl)


    I have created a hotel website with help of Pods. I created custom post types to display the hotels and their rooms, and custom taxonomy types to display the amenities available in each room. So whenever I publish a room, to add the amenities available in that room I tick their respective taxonomies. For instance, if a room has TV and AC, I tick both those taxonomies, and if it doesn’t have them then I leave both taxonomies unchecked.

    The problem is… I’m finding it hard to display the taxonomies that I check with each post. When I insert the following shortcode in my Elementor Page template, it shows all taxonomies that I have created instead of the ones that are applied to post:

    [pods name = "amenity" template = "amenity display template"]

    This shortcode displays the amenities in my desired style (along with an icon on left), but it doesn’t filter the taxonomies based on whether they have been associated with the post or not. I want the shortcode to display only those amenities which I tick while creating the post. You can see my property display page here.

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @ashishonl

    Elementor has it’s own taxonomy/categories modules right? There is no need to use Pods for this.
    The shortcode you’ve posts doesn’t include the ID of the post (required).
    Either you need to remove the name param or you need to add the id param.
    If you remove the name param it will try to find the current object, however, I’m not sure if this will work well with custom Elementor loops.

    Keep in mind that Elementor doesn’t fully support Pods.

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @ashishonl

    Also make sure you check this page: https://pods-pro.skc.dev/downloads/page-builder-toolkit/

    We hope to create a Elementor addon in the near future.

    Cheers, Jory

    Thread Starter ashishonl

    (@ashishonl)

    Hi @keraweb
    Thanks for your response. Eliminating the name parameter is not helping. So I guess I need to use the id parameter in order to do this thing. My question is – how do I instruct the shortcode to fetch the ID of the current post? I can’t insert the ID of any particular post in the shortcode as I want each property page to display the amenities that are tagged with it, so the shortcode must be formatted in such a manner that it fetches the ID of current post automatically. How to do that?

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @ashishonl

    Honestly, I’m not sure how to do that in Elementor. Maybe their support can help you?

    You might try: id="{@globals.post_id}" or id="{@request.ID}" ?
    More info about special magic tags: https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/

    Cheers, Jory

    Thread Starter ashishonl

    (@ashishonl)

    Hi,
    Putting in this shortcode allows me to fetch the exact amenities that are tagged with the post:
    [pods]{@amenity}[/pods]

    However, this shortcode gives me a plain-text output of the amenities. I want the amenities to be displayed according to a Pods template that I have defined, so they appear with their corresponding icons… now only thing I need is a method to pass the value of template in this above given shortcode.

    Thread Starter ashishonl

    (@ashishonl)

    okay so I found a solution myself. I’m posting my solution here so it can be helpful for someone else who is stuck in a similar situation where he wants to fetch the custom taxonomies from a post and wants to display them in a particular manner.

    As I explained in my last reply, using the shortcode [pods]{@taxonomy_name[/pods] was already fetching the desired (i.e. associated) taxonomies from current post, the only issue was that I needed to display the taxonomies in a particular manner (i.e. along with their respective icons that I had added to them through a custom image field. So here is what I did:
    Instead of inserting the Pods template into the shortcode, I directly called the icon field in my like this: [pods]{@taxonomy_name.custom_img_field_name._img}[/pods].

    This started displaying the icons of all those taxonomies which I had tagged with the post. Next part was putting the names of taxonomies next to these icons, which I did by using the each relationship loops:

    [pods][each taxonomy-name]
    <div>{@taxonomy_name.custom_img_field_name._img}&nbsp {@taxonomy_name.name}</div>[/each][/pods]

    As you can see, I have created a div inside the each relationship loop and inside that div I have firstly inserted the shortcode to fetch the image from custom field of each taxonomy, and then after that I have put the shortcode for fetching the title field oof each taxonomy, before closing the div as well as each loop.

    You can also use other HTML styling elements like &nbsp etc. and custom CSS to stylize the way how your taxonomies are displayed.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @ashishonl

    Nice to see you’ve solved it, looks like a perfect solution to me!

    Cheers, Jory

    I’m facing a very similar problem. I have defined a custom taxonomy and associated it to a custom post type (from the Connections tab).

    I’ve tried to add the following shortcodes to a block editor.

    If I do:
    [pods]{@custom_taxonomy_name}[/pods]
    I get an empty output.

    If I do:
    [pods name="custom_taxonomy_name"]{@name}[/pods]
    I get a list of ALL items names of this custom taxonomy, regardless of whether or not they are associated with the particular post (i.e. NOT filtered by the current post ID)

    Any ideas why this might be happening? Any help greatly appreciated.

    Plugin Support Paul Clark

    (@pdclark)

    “name” should contain the name of the Pod, not the field.
    If taxonomy still doesn’t show with magic tags after using the pod name, see https://developer.www.ads-software.com/reference/functions/get_the_terms/

    e.g.,

    <?php
    print_r(
        get_the_terms( get_the_ID(), 'taxonomy-name' )
    );

    Hi, when I do
    [pods]{@custom_taxonomy_name}[/pods]

    The custom_taxonomy_name is referring to the Pod Name with type ‘Custom Taxonomy’.

    I’ve only tried using the shortcode and the pod template. Where should I put the php code that you posted?

    Also, I notice from https://docs.pods.io/displaying-pods/magic-tags/using-magic-tags/ that there’s a note saying: “NOTE: You can only display the Taxonomy content if you have Extended it with Pods. This especially applies to the built-in category or post_tag ; they will not show up in your magic tags if you have not extended the taxonomies.” In my case, my Custom Taxonomy was created as a pod. The post I’ve associated the custom taxonomy with is a custom post type job_listing of WP Job Manager (using the Listify theme). Any special considerations with this set up?

    I figured it out. I had to first extend the custom post type job_listing, and also enable the REST API.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How to display custom taxonomies in associated with a post?’ is closed to new replies.