Custom Fields
Re-Envisioned
Support MB Custom Taxonomy Display Taxonomy Sublevel Only

  • Creator
    Topic
  • #32313
    Intergise
    Participant

    I have a hierarchical taxonomy Destinations. E.g.

    • Tanzania
      • Serengeti
      • Ngorongoro
      • Tarangire

    I want to display just the sublevel of the taxonomy e.g. Serengeti | Ngorongoro | Tarangire.

    Can you please advise how this can be achieved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #32326
    Long Nguyen
    Moderator

    Hi,

    Can you please clarify the question? Where do you want to show the sublevel of a term? On the frontend (field value) or the backend (field select)?

    #32348
    Intergise
    Participant

    Hi Long,

    I want to display them on the front end so it would be a field value.

    What I am trying to do is display a grid of available tours (the CPT). Below the tour name I'd like to display the parks (the sublevel) that a tour goes to. I don't want to display the country (the top level) as it's too broad.

    #32361
    Long Nguyen
    Moderator

    Hi,

    You can use the WordPress functions to get the parent term and child terms of a post. Refer to the documentation
    https://developer.wordpress.org/reference/functions/get_terms/
    https://developer.wordpress.org/reference/functions/get_term_children/

    #32388
    Intergise
    Participant

    Thanks. That displays all of the taxonomy children but what I am looking for is to display only those terms that apply to a specific tour in the post grid.

    See image as an example: Tour post grid example

    I had used:

    <?php echo get_the_term_list( $post->ID, 'destination', '',' | ', ''); ?>

    That works (yellow line which shows the destinations the tour goes to) but want to omit the parent term which is the country (Tanzania in this example).

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.