• My site isn’t live just yet.

    I’m reading what I can and trying to understand how to do this, to no avail. How do I change the breadcrumbs for my about, contact and FAQ pages? I’d like the page slug, the navigation link in the top right corner of my website, and the breadcrumbs to all be the same.

    When I type in a custom name for my about page (“Get to know the writer”), the breadcrumb changes to that same text. In the menu section of my dashboard I was able to change the navigation link back to about.

    Can someone please help me understand the steps I need to take to customize the breadcrumb for each of my five pages? Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ceedee123

    (@ceedee123)

    I found this in the support forum. It seems I need to write a line of code that defines $title with the type and ID. The ID would be a number I’m guessing, and for type I think is_page() is what I need to use.

    I’ll post back here once I figure it out.

    add_filter('bcn_breadcrumb_title', 'my_breadcrumb_title_filter', 11, 3);
    function my_breadcrumb_title_filter($title, $type, $id)
    {
    if(is_single())
    {
    //Update title with whatever you want here, use the $type array entities and $id to help you
    }
    return $title;
    }
    Plugin Author John Havlik

    (@mtekk)

    Yes, to do this you will need to write a filter that hooks into bcn_breadcrumb_title. Within this filter, rather than check is_single() check $id against the ID of the resource you want to change the title for (also check that the post type you’re looking for is in the $type array, otherwise you may get unexpected results). If you have several pages you want to manually set the title on, this may get a little cumbersome.

    If you don’t want to write your own code for this, the Title Trixx extension provides an interface to do this in the post edit page.

    Thread Starter ceedee123

    (@ceedee123)

    You wrote: “Within this filter, rather than check is_single() check $id against the ID of the resource you want to change the title for (also check that the post type you’re looking for is in the $type array, otherwise you may get unexpected results).”

    So, replace ‘is_single’ with the one in your array for pages? And then check for the id number of the page I’m targeting?

    Isn’t ‘is_page’ (or whichever one you’re using) the same as checking for post type? Or is checking to make sure it’s in the array a separate statement I need to write?

    Something like this?

    if(in_array('post-page', $type) && (int) $id === MYPAGEID)

    • This reply was modified 6 years, 9 months ago by ceedee123.
    Plugin Author John Havlik

    (@mtekk)

    So, replace ‘is_single’ with the one in your array for pages? And then check for the id number of the page I’m targeting?

    Yes, check for ‘post-page’ being a member of the $type array rather than is_single() is recommended.

    Isn’t ‘is_page’ (or whichever one you’re using) the same as checking for post type? Or is checking to make sure it’s in the array a separate statement I need to write?

    Checking is_page() only works if you currently are on a page. Checking the $type array passed into the filter is safer as it is guarenteed to apply to the breadcrumb in the breadcrumb trail that you are filtering/modifying the title.

    Something like this?
    if(in_array('post-page', $type) && (int) $id === MYPAGEID)

    Yes.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Changing page breadcrumbs’ is closed to new replies.