Breadcrumbs issue in version 3.40 – Google validation
-
I am still rebuilding my site from scratch to your latest version as your update completely ruined it – see my earlier post.
I am not going live with it yet – I still have a lot of work to do, not to mention your constant updates.
However, I noticed that the schema breadcrumb issue (“data-vocabulary.org schema deprecated”) is causing problems in version 3.40 according to Google validation. I hope you will provide a code for me to solve this problem even if this is an earlier version – this issue should have been dealt with earlier.
- This topic was modified 4 years, 7 months ago by mica123.
-
The latest Responsive theme v4.3.1 schema.org com We recommend you to update to the latest Responsive theme.
For breadcrumb code, please refer to the following function in file core/includes/functions-extensions.php.
function responsive_breadcrumb_lists() {
..
..
}To check the diff between the two releases run the following command.
diff -buar <responsive3.40-directory> <responsive4.3.1-directory> > diff.txtThank you.
Thank you but I did tell you that I am not going to update my live site to the latest Responsive theme until I sort out the damage your latest update did to it. Not to mention the fact that you are still updating the theme – it is now 4.3.1 which I didn’t know – this is extremely worrying. I just want to update the breadcrumb schema. So are you saying that I have to replace this code from responsive3.40:
function responsive_breadcrumb_lists() { /* === OPTIONS === */ $text['home'] = __( 'Home', 'responsive' ); // text for the 'Home' link $text['category'] = __( 'Archive for %s', 'responsive' ); // text for a category page $text['search'] = __( 'Search results for: %s', 'responsive' ); // text for a search results page $text['tag'] = __( 'Posts tagged %s', 'responsive' ); // text for a tag page $text['author'] = __( 'View all posts by %s', 'responsive' ); // text for an author page $text['404'] = __( 'Error 404', 'responsive' ); // text for the 404 page $show['current'] = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show $show['home'] = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $delimiter = ' <span class="chevron">›</span> '; // delimiter between crumbs $before = '<span class="breadcrumb-current">'; // tag before the current crumb $after = '</span>'; // tag after the current crumb /* === END OF OPTIONS === */ $home_link = home_url( '/' ); $before_link = '<span class="breadcrumb" typeof="v:Breadcrumb" vocab="https://schema.org/">'; $after_link = '</span>'; $link_att = ' rel="v:url" property="v:title"'; $link = $before_link . '<a' . $link_att . ' href="%1$s">%2$s</a>' . $after_link; $post = get_queried_object(); $parent_id = isset( $post->post_parent ) ? $post->post_parent : ''; $html_output = ''; if ( is_front_page() ) { if ( 1 == $show['home'] ) { $html_output .= '<div class="breadcrumb-list"><a href="' . $home_link . '">' . $text['home'] . '</a></div>'; } } else { $html_output .= '<div class="breadcrumb-list" xmlns:v="https://rdf.data-vocabulary.org/#">' . sprintf( $link, $home_link, $text['home'] ) . $delimiter; if ( is_home() ) { if ( 1 == $show['current'] ) { $html_output .= $before . get_the_title( get_option( 'page_for_posts', true ) ) . $after; } } elseif ( is_category() ) { $this_cat = get_category( get_query_var( 'cat' ), false ); if ( 0 != $this_cat->parent ) { $cats = get_category_parents( $this_cat->parent, true, $delimiter ); $cats = str_replace( '<a', $before_link . '<a' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $html_output .= $cats; } $html_output .= $before . sprintf( $text['category'], single_cat_title( '', false ) ) . $after; } elseif ( is_search() ) { $html_output .= $before . sprintf( $text['search'], get_search_query() ) . $after; } elseif ( is_day() ) { $html_output .= sprintf( $link, get_year_link( get_the_time( 'Y' ) ), get_the_time( 'Y' ) ) . $delimiter; $html_output .= sprintf( $link, get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ), get_the_time( 'F' ) ) . $delimiter; $html_output .= $before . get_the_time( 'd' ) . $after; } elseif ( is_month() ) { $html_output .= sprintf( $link, get_year_link( get_the_time( 'Y' ) ), get_the_time( 'Y' ) ) . $delimiter; $html_output .= $before . get_the_time( 'F' ) . $after; } elseif ( is_year() ) { $html_output .= $before . get_the_time( 'Y' ) . $after; } elseif ( is_single() && ! is_attachment() ) { if ( 'post' != get_post_type() ) { $post_type = get_post_type_object( get_post_type() ); $archive_link = get_post_type_archive_link( $post_type->name ); $html_output .= sprintf( $link, $archive_link, $post_type->labels->singular_name ); if ( 1 == $show['current'] ) { $html_output .= $delimiter . $before . get_the_title() . $after; } } else { $cat = get_the_category(); $cat = $cat[0]; $cats = get_category_parents( $cat, true, $delimiter ); if ( 0 == $show['current'] ) { $cats = preg_replace( "#^(.+)$delimiter$#", '$1', $cats ); } $cats = str_replace( '<a', $before_link . '<a' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $html_output .= $cats; if ( 1 == $show['current'] ) { $html_output .= $before . get_the_title() . $after; } } } elseif ( ! is_single() && ! is_page() && ! is_404() && 'post' != get_post_type() ) { $post_type = get_post_type_object( get_post_type() ); $html_output .= $before . $post_type->labels->singular_name . $after; } elseif ( is_attachment() ) { $parent = get_post( $parent_id ); $cat = get_the_category( $parent->ID ); if ( isset( $cat[0] ) ) { $cat = $cat[0]; } if ( $cat ) { $cats = get_category_parents( $cat, true, $delimiter ); $cats = str_replace( '<a', $before_link . '<a' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $html_output .= $cats; } $html_output .= sprintf( $link, get_permalink( $parent ), $parent->post_title ); if ( 1 == $show['current'] ) { $html_output .= $delimiter . $before . get_the_title() . $after; } } elseif ( is_page() && ! $parent_id ) { if ( 1 == $show['current'] ) { $html_output .= $before . get_the_title() . $after; } } elseif ( is_page() && $parent_id ) { $breadcrumbs = array(); while ( $parent_id ) { $page_child = get_post( $parent_id ); $breadcrumbs[] = sprintf( $link, get_permalink( $page_child->ID ), get_the_title( $page_child->ID ) ); $parent_id = $page_child->post_parent; } $breadcrumbs = array_reverse( $breadcrumbs ); for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) { $html_output .= $breadcrumbs[ $i ]; if ( $i != count( $breadcrumbs ) - 1 ) { $html_output .= $delimiter; } } if ( 1 == $show['current'] ) { $html_output .= $delimiter . $before . get_the_title() . $after; } } elseif ( is_tag() ) { $html_output .= $before . sprintf( $text['tag'], single_tag_title( '', false ) ) . $after; } elseif ( is_author() ) { $user_id = get_query_var( 'author' ); $userdata = get_the_author_meta( 'display_name', $user_id ); $html_output .= $before . sprintf( $text['author'], $userdata ) . $after; } elseif ( is_404() ) { $html_output .= $before . $text['404'] . $after; } if ( get_query_var( 'paged' ) || get_query_var( 'page' ) ) { $page_num = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' ); $html_output .= $delimiter . sprintf( __( 'Page %s', 'responsive' ), $page_num ); } $html_output .= '</div>'; } echo $html_output; } // end responsive_breadcrumb_lists
to this code from 4.3.1:
function responsive_get_breadcrumb_lists() { $responsive_options = get_option( 'responsive_theme_options' ); $yoast_options = get_option( 'wpseo_titles' ); if ( 1 == $responsive_options['breadcrumb'] ) { return; } elseif ( function_exists( 'yoast_breadcrumb' ) && true === $yoast_options['breadcrumbs-enable'] ) { yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' ); } else { responsive_breadcrumb_lists(); } if ( ! function_exists( 'responsive_breadcrumb_lists' ) ) { /** * Breadcrumb Lists * Allows visitors to quickly navigate back to a previous section or the root page. */ function responsive_breadcrumb_lists() { /* === OPTIONS === */ $text['home'] = __( 'Home', 'responsive' ); // text for the 'Home' link. /* translators: %s: Categories */ $text['category'] = __( 'Archive for %s', 'responsive' ); // text for a category page. /* translators: %s: Search result page */ $text['search'] = __( 'Search results for: %s', 'responsive' ); // text for a search results page. /* translators: %s: Post Pages */ $text['tag'] = __( 'Posts tagged %s', 'responsive' ); // text for a tag page. /* translators: %s: Author pages */ $text['author'] = __( 'View all posts by %s', 'responsive' ); // text for an author page. $text['404'] = __( 'Error 404', 'responsive' ); // text for the 404 page. $show['current'] = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show. $show['home'] = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show. $delimiter = ' <span class="chevron">›</span> '; // delimiter between crumbs. $before = '<span class="breadcrumb-current">'; // tag before the current crumb. $after = '</span>'; // t ag after the current crumb. /* === END OF OPTIONS === */ $home_link = home_url( '/' ); $before_link = '<span class="breadcrumb" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">'; $after_link = '</span>'; $link_att = ''; $link = $before_link . '<a itemprop="item"' . $link_att . ' href="%1$s"><span itemprop="name">%2$s</span></a>' . $after_link; $post = get_queried_object(); if ( is_front_page() ) { if ( 1 == $show['home'] ) { $html_output .= '<div class="breadcrumb-list"><a itemprop="item" href="' . $home_link . '"><span itemprop="name">' . $text['home'] . '</span></a></div>'; } } else { $html_output .= '<div class="breadcrumb-list">' . sprintf( $link, $home_link, $text['home'] ) . $delimiter; if ( is_home() ) { $this_cat = get_category( get_query_var( 'cat' ), false ); if ( 0 != $this_cat->parent ) { $parent = get_category( $this_cat->parent ); $cats = get_category_parents( $this_cat->parent, true, $delimiter ); $cats = str_replace( '<a', $before_link . '<a itemprop="item"' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $cats = str_replace( $parent->name, '<span itemprop="name">' . $parent->name . '</span>' . $after_link, $cats ); $html_output .= $cats; } $html_output .= $before . sprintf( $text['category'], single_cat_title( '', false ) ) . $after; $cats = preg_replace( "#^(.+)$delimiter$#", '$1', $cats ); } $cats = str_replace( '<a', $before_link . '<a itemprop="item"' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $cats = str_replace( $cat->name, '<span itemprop="name">' . $cat->name . '</span>' . $after_link, $cats ); $html_output .= $cats; if ( 1 == $show['current'] ) { if ( $cat ) { $cats = get_category_parents( $cat, true, $delimiter ); $cats = str_replace( '<a', $before_link . '<a itemprop="item"' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $cats = str_replace( $cat->name, '<span itemprop="name">' . $cat->name . '</span>' . $after_link, $cats ); $html_output .= $cats; } if ( get_query_var( 'paged' ) || get_query_var( 'page' ) ) { $page_num = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' ); /* translators: %s: Page Number */ $html_output .= $delimiter . sprintf( __( 'Page %s', 'responsive' ), $page_num ); } libxml_use_internal_errors( true ); $doc = new DOMDocument(); $doc->loadHTML( $html_output ); $finder = new DomXPath( $doc ); $classname = 'breadcrumb'; $nodes = $finder->query( "//span[contains(@class, '$classname')]" ); $position = 1; foreach ( $nodes as $node ) { if ( $position != $nodes->length ) { $fragment = $doc->createDocumentFragment(); $fragment->appendXML( '<meta itemprop="position" content="' . $position . '" />' ); $node->appendChild( $fragment ); $position++; } } echo $doc->saveHTML(); // phpcs:ignore } // end responsive_breadcrumb_lists.
Can you please confirm this – I would not like to ruin my live site which is still on 3.40. As I said earlier, I am still rebuilding my site locally from scratch with your latest version and will not make live until I am satisfied that it will not be ruined again. Sorry, but where am I supposed to use
diff -buar <responsive3.40-directory> <responsive4.3.1-directory> > diff.txt
In any case, I would appreciate it if you would confirm that replacing the code in functions_extentions.php in 3.40 will be sufficient.
Also, please do not mark this topic as resolved because it is not resolved yet. Thank you.- This reply was modified 4 years, 7 months ago by mica123.
The breadcrumb code replacement is not sufficient for Google’s schema.org compatibility.
We have made changes in the multiple files to be compatible the Google’s schema.org.
Please check and refer to the diff between Responsive theme v3.40 and v4.3.1
Thank You.
I am sorry but your reply is not very helpful. I did ask where I am supposed to use this code:
diff -buar <responsive3.40-directory> <responsive4.3.1-directory> > diff.txt
Simply telling me to use it is not enough. I need to have more instructions. Thank you.
Further to my earlier reply:
1. I am not looking for all the differences between version 3.40 and 4.3.1. I am only looking for the differences regarding the breadcrumbs. So your suggested code is not helpful at all, not to mention the fact that I don’t know where and how I should use it. And even if I do find the differences with breadcrumbs, I would not know how to implement them in version 3.40 safely and without risk. This will have to be confirmed by you.
2. May I remind you that your updates ruined my site and I am still reconstructing it from scratch locally. I won’t be able to update the live site until I finish the reconstruction which is still some time off. I would appreciate it if you could make a constructive suggestion than leaving me high and dry again.
You need to find out the difference between the two directories(responsive theme v3.40 and 4.3.1).
You can search on google “find a difference between two directories”. We can’t put any link to over here.
Thank you.
Yes, I did find the difference regarding breadcrumbs between these two versions. One is in functions-extensions and one is in loop-header. All I want from you is whether replacing the code in both functions-extentions and loop-header in version 3.40 will be sufficient. Here are the codes:
from 4.3.1 loop-header to put into functions-extentions 3.40:$responsive_show_breadcrumbs = true; if ( is_front_page() || ( 1 == $responsive_options['breadcrumb'] ) ) { $responsive_show_breadcrumbs = false; } if ( ! $responsive_page_title && ! $responsive_page_description && ! $responsive_show_breadcrumbs ) { return; } ?> <div class="site-content-header"> <?php if ( $responsive_show_breadcrumbs && ( 'before' === get_theme_mod( 'responsive_breadcrumb_position', 'before' ) ) ) : ?> <div class="breadcrumbs" <?php responsive_schema_markup( 'breadcrumb' ); ?>> <?php responsive_get_breadcrumb_lists(); ?> </div> <?php endif; if ( $responsive_page_title || $responsive_page_description ) : ?> <div class="page-header"> <h1 class="page-title"><?php echo wp_kses_post( $responsive_page_title ); ?></h1> <div class="page-description"><?php echo wp_kses_post( $responsive_page_description ); ?></div> </div> <?php endif; if ( $responsive_show_breadcrumbs && ( 'after' === get_theme_mod( 'responsive_breadcrumb_position', 'before' ) ) ) : ?> <div class="breadcrumbs" <?php responsive_schema_markup( 'breadcrumb' ); ?>> <?php responsive_get_breadcrumb_lists(); ?> </div> <?php endif; ?>
and from functions-extentions 3.40 to put into functions-extentions 4.3.1:
function responsive_breadcrumb_lists() { /* === OPTIONS === */ $text['home'] = __( 'Home', 'responsive' ); // text for the 'Home' link. /* translators: %s: Categories */ $text['category'] = __( 'Archive for %s', 'responsive' ); // text for a category page. /* translators: %s: Search result page */ $text['search'] = __( 'Search results for: %s', 'responsive' ); // text for a search results page. /* translators: %s: Post Pages */ $text['tag'] = __( 'Posts tagged %s', 'responsive' ); // text for a tag page. /* translators: %s: Author pages */ $text['author'] = __( 'View all posts by %s', 'responsive' ); // text for an author page. $text['404'] = __( 'Error 404', 'responsive' ); // text for the 404 page. $show['current'] = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show. $show['home'] = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show. $delimiter = ' <span class="chevron">›</span> '; // delimiter between crumbs. $before = '<span class="breadcrumb-current">'; // tag before the current crumb. $after = '</span>'; // t ag after the current crumb. /* === END OF OPTIONS === */ $home_link = home_url( '/' ); $before_link = '<span class="breadcrumb" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">'; $after_link = '</span>'; $link_att = ''; $link = $before_link . '<a itemprop="item"' . $link_att . ' href="%1$s"><span itemprop="name">%2$s</span></a>' . $after_link; $post = get_queried_object(); $parent_id = isset( $post->post_parent ) ? $post->post_parent : ''; $html_output = ''; if ( is_front_page() ) { if ( 1 == $show['home'] ) { $html_output .= '<div class="breadcrumb-list"><a itemprop="item" href="' . $home_link . '"><span itemprop="name">' . $text['home'] . '</span></a></div>'; } } else { $html_output .= '<div class="breadcrumb-list">' . sprintf( $link, $home_link, $text['home'] ) . $delimiter; if ( is_home() ) { if ( 1 == $show['current'] ) { $html_output .= $before . get_the_title( get_option( 'page_for_posts', true ) ) . $after; } } elseif ( is_category() ) { $this_cat = get_category( get_query_var( 'cat' ), false ); if ( 0 != $this_cat->parent ) { $parent = get_category( $this_cat->parent ); $cats = get_category_parents( $this_cat->parent, true, $delimiter ); $cats = str_replace( '<a', $before_link . '<a itemprop="item"' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $cats = str_replace( $parent->name, '<span itemprop="name">' . $parent->name . '</span>' . $after_link, $cats ); $html_output .= $cats; } $html_output .= $before . sprintf( $text['category'], single_cat_title( '', false ) ) . $after; } elseif ( is_search() ) { $html_output .= $before . sprintf( $text['search'], get_search_query() ) . $after; } elseif ( is_day() ) { $html_output .= sprintf( $link, get_year_link( get_the_time( 'Y' ) ), get_the_time( 'Y' ) ) . $delimiter; $html_output .= sprintf( $link, get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ), get_the_time( 'F' ) ) . $delimiter; $html_output .= $before . get_the_time( 'd' ) . $after; } elseif ( is_month() ) { $html_output .= sprintf( $link, get_year_link( get_the_time( 'Y' ) ), get_the_time( 'Y' ) ) . $delimiter; $html_output .= $before . get_the_time( 'F' ) . $after; } elseif ( is_year() ) { $html_output .= $before . get_the_time( 'Y' ) . $after; } elseif ( is_single() && ! is_attachment() ) { if ( 'post' != get_post_type() ) { $post_type = get_post_type_object( get_post_type() ); $archive_link = get_post_type_archive_link( $post_type->name ); $html_output .= sprintf( $link, $archive_link, $post_type->labels->singular_name ); if ( 1 == $show['current'] ) { $html_output .= $delimiter . $before . get_the_title() . $after; } } else { $cat = get_the_category(); $cat = $cat[0]; $cats = get_category_parents( $cat, true, $delimiter ); if ( 0 == $show['current'] ) { $cats = preg_replace( "#^(.+)$delimiter$#", '$1', $cats ); } $cats = str_replace( '<a', $before_link . '<a itemprop="item"' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $cats = str_replace( $cat->name, '<span itemprop="name">' . $cat->name . '</span>' . $after_link, $cats ); $html_output .= $cats; if ( 1 == $show['current'] ) { $html_output .= $before . get_the_title() . $after; } } } elseif ( ! is_single() && ! is_page() && ! is_404() && 'post' != get_post_type() ) { $post_type = get_post_type_object( get_post_type() ); $html_output .= $before . $post_type->labels->singular_name . $after; } elseif ( is_attachment() ) { $parent = get_post( $parent_id ); $cat = get_the_category( $parent->ID ); if ( isset( $cat[0] ) ) { $cat = $cat[0]; } if ( $cat ) { $cats = get_category_parents( $cat, true, $delimiter ); $cats = str_replace( '<a', $before_link . '<a itemprop="item"' . $link_att, $cats ); $cats = str_replace( '</a>', '</a>' . $after_link, $cats ); $cats = str_replace( $cat->name, '<span itemprop="name">' . $cat->name . '</span>' . $after_link, $cats ); $html_output .= $cats; } $html_output .= sprintf( $link, get_permalink( $parent ), $parent->post_title ); if ( 1 == $show['current'] ) { $html_output .= $delimiter . $before . get_the_title() . $after; } } elseif ( is_page() && ! $parent_id ) { if ( 1 == $show['current'] ) { $html_output .= $before . get_the_title() . $after; } } elseif ( is_page() && $parent_id ) { $breadcrumbs = array(); while ( $parent_id ) { $page_child = get_post( $parent_id ); $breadcrumbs[] = sprintf( $link, get_permalink( $page_child->ID ), get_the_title( $page_child->ID ) ); $parent_id = $page_child->post_parent; } $breadcrumbs = array_reverse( $breadcrumbs ); for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) { $html_output .= $breadcrumbs[ $i ]; if ( $i != count( $breadcrumbs ) - 1 ) { $html_output .= $delimiter; } } if ( 1 == $show['current'] ) { $html_output .= $delimiter . $before . get_the_title() . $after; } } elseif ( is_tag() ) { $html_output .= $before . sprintf( $text['tag'], single_tag_title( '', false ) ) . $after; } elseif ( is_author() ) { $user_id = get_query_var( 'author' ); $userdata = get_the_author_meta( 'display_name', $user_id ); $html_output .= $before . sprintf( $text['author'], $userdata ) . $after; } elseif ( is_404() ) { $html_output .= $before . $text['404'] . $after; } if ( get_query_var( 'paged' ) || get_query_var( 'page' ) ) { $page_num = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' ); /* translators: %s: Page Number */ $html_output .= $delimiter . sprintf( __( 'Page %s', 'responsive' ), $page_num ); } $html_output .= '</div>'; } libxml_use_internal_errors( true ); $doc = new DOMDocument(); $doc->loadHTML( $html_output ); $finder = new DomXPath( $doc ); $classname = 'breadcrumb'; $nodes = $finder->query( "//span[contains(@class, '$classname')]" ); $position = 1; foreach ( $nodes as $node ) { if ( $position != $nodes->length ) { $fragment = $doc->createDocumentFragment(); $fragment->appendXML( '<meta itemprop="position" content="' . $position . '" />' ); $node->appendChild( $fragment ); $position++; } } echo $doc->saveHTML(); // phpcs:ignore } // end responsive_breadcrumb_lists.
I hope for constructive help this time. Thank you.
This may fix the breadcrumb issue, but not sure about the “data-vocabulary.org schema deprecated”. We have made many changes in the Responsive theme till now.
If you find any bug in any of the releases, please let us know. We will fix the bug in the upcoming releases of the Responsive theme.
Thank you.
Please update the theme to the latest release v4.3.4 of the Responsive theme. The latest theme is compatible with Google’s schema.org.
Thank you.
See my reply in another topic. Thank you.
- The topic ‘Breadcrumbs issue in version 3.40 – Google validation’ is closed to new replies.