RDF schema markup for unlinked template
-
I am using the following to create custom breadcrumb structure for different situations.
function create__custom_breadcrumbs( $breadcrumb ) { if ( !is_tax( ['product-categories','applications', 'parameters'] ) && !is_singular( ['products'] )) { return; } // Breadcrumb templates. $breadcrumb_template_link = '<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>'; $breadcrumb_template_nolink = '<span class="breadcrumb-link-wrap" property="itemListElement" typeof="ListItem" itemscope="" itemtype="https://schema.org/ListItem" property="item" typeof="ListItem"><span property="item" typeof="WebPage" resource="/current-page.html" ><span property="name">%htitle%</span></span><meta property="position" content="%position%"></span>'; /** * Store the first and last breadcrumbs, we're rebuilding the middle part. */ $breadcrumb_root = reset( $breadcrumb->breadcrumbs ); $breadcrumb_end = end( $breadcrumb->breadcrumbs ); $obj = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $tax = $obj->taxonomy; $term_name = $obj->name; // $id = $obj->term_id; // print_r($obj); if ( is_tax( 'product-categories' ) ) { /** * Build our custom product category breadcrumb. */ $products = get_post_type_object( 'products' ); $breadcrumb_title = __( 'Products', 'products' ); $breadcrumb_link = get_site_url().'/'.$products->rewrite['slug'].'/'; $breadcrumb_setup = new bcn_breadcrumb( $breadcrumb_title, $breadcrumb_template_link, [], $breadcrumb_link ); } elseif ( is_tax( ['applications','parameters'] ) ) { $tax = get_taxonomy( $tax ); $tax_name = $tax->label; $breadcrumb_title = __( $tax_name, $tax_name ); $breadcrumb_link = get_site_url().'/'.$tax->rewrite['slug'].'/'; $breadcrumb_setup = new bcn_breadcrumb( $breadcrumb_title, $breadcrumb_template_link, [], $breadcrumb_link ); $breadcrumb_root = new bcn_breadcrumb( $term_name, $breadcrumb_template_nolink, [], '' ); } elseif ( is_singular( ['products'] ) ) { $breadcrumb_end = new bcn_breadcrumb( 'Home', $breadcrumb_template_link, [], get_site_url() ); $product_id = get_the_ID(); $product_name = get_the_title($product_id); $tax = get_the_terms( $product_id, 'product-categories' )[0]; $tax_name = $tax->name; $breadcrumb_title = __( $tax_name, $tax_name ); $breadcrumb_link = get_site_url().'/product-categories/'.$tax->slug.'/'; $breadcrumb_setup = new bcn_breadcrumb( $breadcrumb_title, $breadcrumb_template_link, [], $breadcrumb_link ); $breadcrumb_root = new bcn_breadcrumb( $product_name, $breadcrumb_template_nolink, [], '' ); } /** * Update the Breadcrumb NavXT object. */ $breadcrumb->breadcrumbs = [ $breadcrumb_root, $breadcrumb_setup, $breadcrumb_end, ]; }
The issue is with rendering of the non-link RDF schema attributes. I am trying to give the non-link template a ‘resources’ attribute, which seems to be validate markup according to https://search.google.com/structured-data/testing-tool but when I include it in this code it is not rendering the resource attribute at all.
Is there something that is removing this? If so is there a way around this?
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘RDF schema markup for unlinked template’ is closed to new replies.