• Resolved Sandra Romano

    (@sandraromano)


    Hello! I need to display through a template the parent taxonomy term name of a taxonomy term. It is, of course, a custom Pods Taxonomy, named “corpus_externo”, but I am only able to display its ID. I want the parent term to be the displayed text and the child term to be the URL underneath. Every parent term will have several different children with different URLs.

    My code is:

    [each corpus_externo]
    <a href="{@name}">{@corpus_externo.parent}</a>
    [/each]	

    What I am doing wrong? I got just ID numbers instead of the name of the parent. The link, however, works perfectly.

    Thanks for any help!

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

    (@keraweb)

    Hi @sandraromano

    The parent traversal isn’t retuning an object but the actual database value, this is why it’s not working

    I don’t think such a traversal is supported at the moment.
    You could try to traverse further like this: {@corpus_externo.parent.name}
    If this doesn’t work then you should create helper functions for this.
    Example:

    function get_term_name( $term_id ) {
        $term = get_term( $term_id );
        return $term ? $term->name : '';
    }

    You can then use this function in your magic tags: {@corpus_externo.parent,get_term_name}

    Cheers, Jory

    Thread Starter Sandra Romano

    (@sandraromano)

    Thanks a lot! It worked perfectly. I had tried the first approach, but it broke the tag. The helper function is what I needed.

    Many, many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Parent Taxonomy Name in template’ is closed to new replies.