Yoast Breadcrumbs (SEO) and Events Manager fix
-
Here is a bit of code I used to get around Events Manager’s way of doing single events so the plugin will work with Yoast SEO’s breadcrumb function. It is not 100% foolproof but it works well enough for what I needed. I use it in header.php of my theme.
<?php //check if breadcrumbs and events manager functions exist if (function_exists('yoast_breadcrumb') && !is_front_page()) : ?> <div id="breadcrumb_wrapper" class="clearfix"> <?php // set your before and after tags for breadcrumbs $bc_start = '<nav id="breadcrumbs"><div>'; $bc_end = '</div></nav>'; // if is one of your pages that have events manager if ( ( is_page('Events') || is_page('Past Events') ) && function_exists( 'em_init' ) ) { // events calendar class global $EM_Event; // get yoast options from database which can be set in yoast internal links settings page $opt = get_option("wpseo_internallinks"); $bc_sep = $opt['breadcrumbs-sep']; $bc_home = $opt['breadcrumbs-home']; if ( em_is_event_page() ) { // single event conditional $this_page = '<a href="'.site_url().'">'.$bc_home.'</a> '.$bc_sep.' <a href="'.get_permalink().'">'.get_the_title().'</a> '.$bc_sep.' <strong>'.$EM_Event->output('#_NAME').'</strong>'; echo $bc_start.$this_page.$bc_end; } else { // multi events list conditional echo $bc_start.'<a href="'.site_url().'">'.$bc_home.'</a> '.$bc_sep.' <strong>'.get_the_title().'</a></strong>'.$bc_end; } } else { // do yoast bc function yoast_breadcrumb( $bc_start, $bc_end ); } ?> </div> <?php endif; ?>
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘Yoast Breadcrumbs (SEO) and Events Manager fix’ is closed to new replies.