Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('bcn_after_fill', 'post_landing_page_breadcrumb_adder');
- function post_landing_page_breadcrumb_adder($breadcrumb_trail)
- {
- /**
- * Get multi-site blog id..
- */
- $site_id = get_current_blog_id();
- /**
- * Only execute if we are on a post..
- */
- if ( ! is_singular( [ 'post' ] ) ) {
- return;
- }
- /**
- * Default breadcrumb template..
- */
- $breadcrumb_template = '<span class="breadcrumb-link-wrap" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" property="itemListElement" typeof="ListItem"><a itemprop="item" property="item" typeof="WebPage" title="Go to %title%." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>';
- /**
- * Store the first and last breadcrumbs, we're rebuilding the middle part..
- */
- $breadcrumb_root = reset( $breadcrumb_trail->breadcrumbs );
- $breadcrumb_end = end( $breadcrumb_trail->breadcrumbs );
- /**
- * Begin building our custom breadcrumb, add in as many conditions as necessary..
- */
- $multisite_page = null;
- $mutlisite_page_breadcrumb_title = null;
- $custom_page = null;
- $breadcrumb_title = null;
- if ( $site_id == 2 ) {
- $multisite_page = get_page_by_path( '/about/' );
- $mutlisite_page_breadcrumb_title = __( 'About' );
- $custom_page = get_page_by_path( '/about/news/' );
- $breadcrumb_title = __( 'News' );
- }
- else if ( $site_id == 3 ) {
- $multisite_page = get_page_by_path( '/admissions/' );
- $mutlisite_page_breadcrumb_title = __( 'Admissions' );
- // WEIRD ITS GIVING ME THE WRONG URL...
- //$custom_page = get_page_by_path( '/admissions/blue-hose/' );
- $custom_page = get_page( 2152 );
- $breadcrumb_title = __( 'Be A Blue Hose' );
- }
- else if ($site_id == 6 ) {
- $multisite_page = get_page_by_path( '/giving/' );
- $mutlisite_page_breadcrumb_title = __( 'Giving' );
- $custom_page = get_page_by_path( '/giving/stories/' );
- $breadcrumb_title = __( 'Stories' );
- }
- else {
- return;
- }
- /**
- * Create the breadcrumb object..
- */
- $mutlisite_page_breadcrumb_link = get_the_permalink( $multisite_page->ID );
- $breadcrumb_link = get_the_permalink( $custom_page->ID );
- $multisite_breadcrumb = new bcn_breadcrumb( $mutlisite_page_breadcrumb_title, $breadcrumb_template, [], $mutlisite_page_breadcrumb_link, $multisite_page->ID );
- $custom_item_breadcrumb = new bcn_breadcrumb( $breadcrumb_title, $breadcrumb_template, [], $breadcrumb_link, $custom_page->ID );
- /**
- * Update the Breadcrumb NavXT object..
- */
- $breadcrumb_trail->breadcrumbs = [
- $breadcrumb_root,
- $custom_item_breadcrumb,
- $multisite_breadcrumb,
- $breadcrumb_end,
- ];
- }
Advertisement
Add Comment
Please, Sign In to add comment