Support

Account

Home Forums Front-end Issues Get the slug of the ancestor category term of a taxonomy field

Unread

Get the slug of the ancestor category term of a taxonomy field

  • Hi!
    I’m having an issue trying to get the slug of the ancestor category of a taxonomy field.

    I have a repeater field called “Slides” that contains a Text field (the title of the slide), a WYSIWYG field (description) and a taxonomy field. I’m just using the default WP category (not custom taxonomy) with three levels of hierarchy.

    So… I need to get two things from the taxonomy field.

    1) The taxonomy term (the easy part, using get_sub_field(‘cat-field’).
    2) The slug of the ancestor category of that taxonomy term (just the immediate one single level UP, not the top-most). I need this slug to use it as a CSS class.

    <p class="cat-{slug-of-the-ancestor}">Taxonomy term</p>

    Can anybody help me please?

Viewing 1 post (of 1 total)

The topic ‘Get the slug of the ancestor category term of a taxonomy field’ is closed to new replies.