• Resolved stephbretagne

    (@stephbretagne)


    Hello,

    First of all, a big thank you for your wonderful work!

    The site I am managing has a special structure. Instead of using archive pages, it uses pages with category names. On these pages, shortcodes generate the list of subcategories + the list of articles in the category with excerpts.
    I would therefore like the breadcrumb trail to respect this structure.

    Example: Home > Your rights > Health at work > Suffering at work

    When I click on “Your rights”, I would like to go to the “Your rights” page and not to the category.
    Is that possible? And if so, how do we do it?

    Thank you in advance for your answer.

    ps: I left this message on your site’s FAQ but it doesn’t appear. If it is waiting for moderation, please excuse me for the duplicated content!

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

    (@mtekk)

    You can do this using the bcn_breadcrumb_url filter. See https://mtekk.us/archives/guides/link-to-a-page-rather-than-the-category-archive-in-a-breadcrumb/ for an example on how to do this. Otherwise, if you not want to write any code, Breadcrumb NavXT Paths provides an interface to map categories to pages.

    Thread Starter stephbretagne

    (@stephbretagne)

    Hello John,

    Thank you very much for this code.
    With the help of a few friends, I made this one to make it work for my many categories:

    add_filter('bcn_breadcrumb_url', 'my_breadcrumb_url_changer', 3, 10);
    function my_breadcrumb_url_changer($url, $type, $id)
    {
    $id = intval($id);
    $link_by_id = array(
    72 => 1165, // actualités
    35 => 1131, // actions
    70 => 1133, // nos actions
    14 => 1142, // santé au travail
    67 => 1140 // vos droits
    );
    if( in_array('category', $type) && !empty($link_by_id[$id]) )
    {
    $url = get_permalink( $link_by_id[$id] );
    }
    return $url;
    }

    Thank you again for your fantastic work!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Breadcrumb for pages instead of categories’ is closed to new replies.