Support » Plugin: Breadcrumb NavXT » Show only main selected category

  • Hello!

    I have some tutorials on my web site and are classified by child categories y only want to show in Breadcrumbs the selected category (in my case is normally the last child category that I want to show)

    Thanks

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

    (@mtekk)

    This sounds similar to this request: https://wordpress.org/support/topic/post-belonging-to-multiple-categories-shows-wrong-bc-trail/

    My answer is similar, you can write code targeting bcn_pick_post_term to select the term you want.

    Flector

    (@flector)

    can you give example?

    Plugin Author John Havlik

    (@mtekk)

    Unfortunately, the actual code you’d use is highly specific to the intended use case and UI you are integrating into. In general, you’d do something like the following:

    add_filter('bcn_pick_post_term', 'my_bcn_pick_term_filter', 10, 4);
    function my_bcn_pick_term_filter($term, $id, $type, $taxonomy)
    {
    if($id === POST_IN_QUESTION)
    {
    //GET POST TERMS HERE
    //Set $term to desired term for post
    }
    return $term;
    }

    Note that there are items here that you will need to write (e.g. retrieving the terms for the post, dealing with the post in question check). This may even not be the way you want to do it (depending on how you’re dealing with the mapping).

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