Page id only breadcrumb trail
-
So I am trying to configure my breadcrumb trail to page id only, I have an example of a website which I want to mimic but I am finding the breadcrumb trail php too difficult to edit.
The website I am trying to mimic is: https://fourdrubber.com/
and the code for my breadcrumbs are as follows.
if ( ! function_exists( 'presscore_get_breadcrumbs' ) ) : /** * Returns breadcrumbs html * original script you can find on https://dimox.net * * @since 1.0.0 * * @return string Breadcrumbs html */ function presscore_get_breadcrumbs( $args = array() ) { $default_args = array( 'text' => array( 'home' => _x('Home', 'breadcrumbs', 'the7mk2'), 'category' => _x('Category "%s"', 'breadcrumbs', 'the7mk2'), 'search' => _x('Results for "%s"', 'breadcrumbs', 'the7mk2'), 'tag' => _x('Entries tagged with "%s"', 'breadcrumbs', 'the7mk2'), 'author' => _x('Article author %s', 'breadcrumbs', 'the7mk2'), '404' => _x('Error 404', 'breadcrumbs', 'the7mk2') ), 'showCurrent' => 1, 'showOnHome' => 1, 'delimiter' => '', 'before' => '<li class="current">', 'after' => '</li>', 'linkBefore' => '<li typeof="v:Breadcrumb">', 'linkAfter' => '</li>', 'linkAttr' => ' rel="v:url" property="v:title"', 'beforeBreadcrumbs' => '', 'afterBreadcrumbs' => '', 'listAttr' => ' class="breadcrumbs text-normal"' ); $args = wp_parse_args( $args, $default_args ); $breadcrumbs_html = apply_filters( 'presscore_get_breadcrumbs-html', '', $args ); if ( $breadcrumbs_html ) { return $breadcrumbs_html; } extract( array_intersect_key( $args, $default_args ) ); $link = $linkBefore . '<a' . $linkAttr . ' href="%1$s" title="">%2$s</a>' . $linkAfter; $breadcrumbs_html .= '<div class="assistive-text">' . _x('You are here:', 'breeadcrumbs', 'the7mk2') . '</div>'; $homeLink = home_url() . '/'; global $post; if (is_home() || is_front_page()) { if ($showOnHome == 1) { $breadcrumbs_html .= '<ol' . $listAttr . '><a href="' . $homeLink . '">' . $text['home'] . '</a></ol>'; } } else { $breadcrumbs_html .= '<ol' . $listAttr . ' xmlns:v="https://rdf.data-vocabulary.org/#">' . sprintf($link, $homeLink, $text['home']) . $delimiter; if ( is_category() ) { $thisCat = get_category(get_query_var('cat'), false); if ($thisCat->parent != 0) { $cats = get_category_parents($thisCat->parent, TRUE, $delimiter); $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats); $cats = str_replace('</a>', '</a>' . $linkAfter, $cats); if(preg_match( '/title="/', $cats ) ===0) { $cats = preg_replace('/title=""/', 'title=""', $cats); } $breadcrumbs_html .= $cats; } $breadcrumbs_html .= $before . sprintf($text['category'], single_cat_title('', false)) . $after; } elseif ( is_search() ) { $breadcrumbs_html .= $before . sprintf($text['search'], get_search_query()) . $after; } elseif ( is_day() ) { $breadcrumbs_html .= sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter; $breadcrumbs_html .= sprintf($link, get_month_link(get_the_time('Y'),get_the_time('m')), get_the_time('F')) . $delimiter; $breadcrumbs_html .= $before . get_the_time('d') . $after; } elseif ( is_month() ) { $breadcrumbs_html .= sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter; $breadcrumbs_html .= $before . get_the_time('F') . $after; } elseif ( is_year() ) { $breadcrumbs_html .= $before . get_the_time('Y') . $after; } elseif ( is_single() && !is_attachment() ) { $post_type = get_post_type(); if ( $post_type != 'post' ) { $post_type_obj = get_post_type_object( $post_type ); $slug = $post_type_obj->rewrite; $breadcrumbs_html .= sprintf($link, get_post_type_archive_link( $post_type ), $post_type_obj->labels->singular_name); if ($showCurrent == 1) { $breadcrumbs_html .= $delimiter . $before . get_the_title() . $after; } } else { $cat = get_the_category(); $cat = $cat[0]; $cats = get_category_parents($cat, TRUE, $delimiter); if ($showCurrent == 0) { $cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats); } $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats); $cats = str_replace('</a>', '</a>' . $linkAfter, $cats); $breadcrumbs_html .= $cats; if ($showCurrent == 1) { $breadcrumbs_html .= $before . get_the_title() . $after; } } } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) { $post_type_obj = get_post_type_object(get_post_type()); if ( $post_type_obj ) { $breadcrumbs_html .= $before . $post_type_obj->labels->singular_name . $after; } } elseif ( is_attachment() ) { if ($showCurrent == 1) { $breadcrumbs_html .= $delimiter . $before . get_the_title() . $after; } } elseif ( is_page() && !$post->post_parent ) { if ($showCurrent == 1) { $breadcrumbs_html .= $before . get_the_title() . $after; } } elseif ( is_page() && $post->post_parent ) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID)); $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { $breadcrumbs_html .= $breadcrumbs[$i]; if ($i != count($breadcrumbs)-1) { $breadcrumbs_html .= $delimiter; } } if ($showCurrent == 1) { $breadcrumbs_html .= $delimiter . $before . get_the_title() . $after; } } elseif ( is_tag() ) { $breadcrumbs_html .= $before . sprintf($text['tag'], single_tag_title('', false)) . $after; } elseif ( is_author() ) { global $author; $userdata = get_userdata($author); $breadcrumbs_html .= $before . sprintf($text['author'], $userdata->display_name) . $after; } elseif ( is_404() ) { $breadcrumbs_html .= $before . $text['404'] . $after; } if ( get_query_var('paged') ) { $breadcrumbs_html .= $before; if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) { $breadcrumbs_html .= ' ('; } $breadcrumbs_html .= _x('Page', 'bredcrumbs', 'the7mk2') . ' ' . get_query_var('paged'); if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) { $breadcrumbs_html .= ')'; } $breadcrumbs_html .= $after; } $breadcrumbs_html .= '</ol>'; } return apply_filters( 'presscore_get_breadcrumbs', $beforeBreadcrumbs . $breadcrumbs_html . $afterBreadcrumbs, $args ); } // end presscore_get_breadcrumbs() endif;
my site is not live and only just in the interim of being built – no content etc,
but the breadcrumb trail is displaying archives and categories which I just plainly don’t want to display.
Kind regards
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Page id only breadcrumb trail’ is closed to new replies.