• Resolved watai

    (@watai78)


    Hi all,

    I have custom post defined such as

    post_type = research
    taxonomy = research_category
    term = book(id:1),thesis(id:2),sub-of-thesis(id:3)….

    Is there a way that I can exclude certain terms by id from showing in the breadcrumbs? For example id = 3?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Havlik

    (@mtekk)

    Is the taxonomy a hierarchical or non-hierarchical taxonomy? Based on the terms you listed, I assume it’s a hierarchical taxonomy. If that is the case, you can use the bcn_pick_post_term filter to force a different term to be picked when term id=3 is set.

    add_filter('bcn_pick_post_term', 'my_bcn_term_filter', 3, 10);
    function my_bcn_term_filter($term, $post_id, $post_type, $term_taxonomy)
    {
    if($term->term_id === 3)
    {
    $term = get_term($term->parent, $term->taxonomy);
    }
    return $term;
    }

    The above example assumes the term you don’t want to use has the term_id of 3, and you wanted to use its parent instead. This can be modified for other term selection behaviors depending on exactly what behavior you want.

    Thread Starter watai

    (@watai78)

    Yes, your’re correct, it is a hierarchical taxonomy. I’ve tried you code and it works flawlessly.

    Thank you John, have a great day ahead !!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude taxonomy term in breadcrumb’ is closed to new replies.