Editing Breadcrumb Output

Community Forums Forums Design Tips and Tricks Editing Breadcrumb Output

This topic is: not resolved

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  ElwoodP 1 year, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30450

    ElwoodP
    Participant
    Post count: 4

    I have some pages on a site that are split into multiple sections using <!–nextpage–>. I wanted to edit the genesis breadcrumb output to reflect which section of the page I was currently on.

    I’ve successfully achieved this (with some very rudimentary php skills!) by editing the function get_page_crumb() found in breadcrumb.php class.

    It works but obviously I don’t want to leave edits in the core genesis file. How do I overwrite the function from my themes functions.php?

    function get_page_crumb() {

    global $wp_query, $page, $numpages;

    if ( ‘page’ == $this->on_front && is_front_page() ) {
    /** Don’t do anything – we’re on the front page and we’ve already dealt with that elsewhere */
    $crumb = $this->get_home_crumb();
    } else {
    $post = $wp_query->get_queried_object();

    /** If this is a top level Page, it’s simple to output the breadcrumb */
    if ( 0 == $post->post_parent ) {
    $crumb = get_the_title();
    } else {
    if ( isset( $post->ancestors ) ) {
    if ( is_array( $post->ancestors ) )
    $ancestors = array_values( $post->ancestors );
    else
    $ancestors = array( $post->ancestors );
    } else {
    $ancestors = array( $post->post_parent );
    }

    $crumbs = array();
    foreach ( $ancestors as $ancestor ) {
    array_unshift(
    $crumbs,
    $this->get_breadcrumb_link(
    get_permalink( $ancestor ),
    sprintf( __( ‘View %s’, ‘genesis’ ), get_the_title( $ancestor ) ),
    get_the_title( $ancestor )
    )
    );
    }

    /** Add the current page title */

    if ($numpages > 1) {
    $crumbs[] = ‘<a href=”‘ . get_permalink( $post ) . ‘”>’ . get_the_title( $post->ID ) . ‘</a> » Part ‘ . $page;
    } else {
    $crumbs[] = get_the_title( $post->ID );
    }

    $crumb = join( $this->args['sep'], $crumbs );
    }
    }

    return apply_filters( ‘genesis_page_crumb’, $crumb, $this->args );

    }
    }

    #30558

    anitac
    Participant
    Post count: 7031

    Here’s some snippets that might help you – http://my.studiopress.com/snippets/breadcrumbs/. And also this – http://code.garyjones.co.uk/modify-breadcrumb-display, and one more here – http://www.wpsyntax.com/wordpress/customize-genesis-breadcrumb.


    Let me help you customize your theme, responsive header, Buddypress, Agentpress or technical issue!
    Visit me here: Cre8tiveDiva.com | Tweet Me! | Plus Me!
    When asking for help, please provide a link or screen shot showing your problem!

    #30573

    ElwoodP
    Participant
    Post count: 4

    Thanks Antiac I’m not sure that helps. As far as I can work out I can use filters to change various static parts of the breadcrumb but I can’t use filters to achieve what I’m after?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.