Community Forums › Forums › Archived Forums › Design Tips and Tricks › Genesis Breadcrumb Filter
- This topic has 5 replies, 2 voices, and was last updated 8 years, 6 months ago by emmtre.
-
AuthorPosts
-
September 2, 2015 at 2:31 pm #164359emmtreParticipant
Is there a Genesis breadcrumb filter similar to "wpseo_breadcrumb_links" in Yoast SEO that can be used to only display the main category for blog posts?
With Yoast SEO I have used the code snipet below to display only the main category "Blog" and hide sub categories to match the permalink structure and url for blog posts.
I have a site where we are going to try out another SEO plugin but would like to have the same breadcrumb structure.
//* Customize single post breadcrumb add_filter( 'wpseo_breadcrumb_links', 'custom_post_breadcrumb' ); function custom_post_breadcrumb( $links ) { if( is_single() ) { $breadcrumb[] = array( 'url' => get_page_link( get_page_by_title( 'Blog' ) ), 'text' => 'Blog', ); array_splice( $links, 1, -2, $breadcrumb ); } return $links; }
September 4, 2015 at 6:22 pm #164631Brad DaltonParticipantYes and seen the code for it several times on these forums.
Also, this may help http://wpsites.net/web-design/change-breadcrumbs-in-genesis/
September 5, 2015 at 3:36 am #164652emmtreParticipantThanx Brad! I know about the usual bredcrumb filters but I'm looking for a way to exclude sub-categories in the breadcrumb for single posts and only display the main category in the breadcrumb to match the permalink settings. I have tried to search these forums and other sites but without success. Any other resources you can recommend? I have looked at genesis_breadcrumb_link, genesis_single_crumb and genesis_category_crumb but I can't figure out if it can be used for this.
September 5, 2015 at 4:09 am #164654Brad DaltonParticipantI would look for the code which excludes sub cats and test it with the filter for genesis breadcrumbs.
September 5, 2015 at 11:27 am #164672emmtreParticipantOK I found some code examples from Bill Erickson. I skipped the idea to use only the main category and used a blog page instead in the breadcrumb to mimic the code above. The front page displays the latest post so this is another blog page. I guess this will work but then the new schema.org markup of bredcrumbs is missing. Any other ideas or filters to use to keep the markup or do I have to add it manually?
//* Customize single post breadcrumb add_filter( 'genesis_single_crumb', 'custom_single_crumb', 10, 2 ); function custom_single_crumb( $crumb, $args ) { if( is_singular( 'post' ) ) { $crumb = get_the_title(); return '<a href="' . get_page_link( get_page_by_title( 'Blog' ) ) . '">' . Blog .'</a> ' . $args['sep'] . ' ' . $crumb; } }
September 5, 2015 at 2:17 pm #164687emmtreParticipantThe manually way to add the new markup of breadcrumbs in Genesis 2.2. Can genesis_build_crumbs or any other filter be used to add the markup automatically?
//* Customize single post breadcrumb add_filter( 'genesis_single_crumb', 'custom_single_crumb', 10, 2 ); function custom_single_crumb( $crumb, $args ) { $url = get_page_link( get_page_by_title( 'Blog' ) ); $title = Blog; if( is_singular( 'post' ) ) { $crumb = get_the_title(); return '<span class="breadcrumb-link-wrap" itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem"><a href="' . $url . '" itemprop="item"><span itemprop="name">' . $title .'</span></a></span>' . $args['sep'] . $crumb; } else { return $crumb; } }
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.