Tagged: breadcrumb, enfold
-
AuthorPosts
-
June 16, 2021 at 8:07 pm #1306090
Hello
I have followed up on the instructions to create your own breadcrumb:
function av_breadcrumbs_shortcode( $atts ) { return avia_breadcrumbs(array('separator' => '/', 'richsnippet' => true)); } add_shortcode( 'av_breadcrumbs', 'av_breadcrumbs_shortcode' );
Then add breadcrumbs using following shortcode
[av_breadcrumbs]
It works great, but there is no structured data. I noticed when using the default breadcrumb, there is structured data. How can I get structured data for this shortcode version?
Thank you.
June 18, 2021 at 6:24 am #1306288Hi Benp,
What do you mean by structured data?
Do you perhaps want to pass some attributes to the avia_breadcrumbs?
Also, avia_breadcrumbs is deprecated since 4.8.2, please use Avia_Breadcrumb_Trail()->get_trail( $args ) instead.Best regards,
NikkoJune 18, 2021 at 11:46 pm #1306452Hello Nikko
I’m a bit confused.
Perhaps I should rewind a few steps. I would to:
1. create a shortcode for the enfold breadcrumbs.
2. include structured breadcrumb schema for the breadcrumbs. I noticed that the default breadcrumb option provides this, but the shortcode I created based on another guide did not.
3. Remove the word blog from the breadcrumbs. This is automatically added as the second value, e.g. home > blog > category > post nameCurrently I have:
/* Remove blog from shortcode */ add_filter( 'avia_breadcrumbs_trail', 'avia_breadcrumbs_trail_mod', 50, 2 ); function avia_breadcrumbs_trail_mod( $trail, $args ) { if ( is_single() ) { unset($trail[1]); } return $trail; }
and:
/* Breadcrumb shortcode */ add_shortcode('breadcrumbs', 'avia_breadcrumbs');
June 19, 2021 at 4:31 am #1306463Hi Benp,
The first shortcode should still work, as for the second code use it only if you are on Enfold 4.8.1 and below, for 4.8.2 and above just replace:
/* Breadcrumb shortcode */ add_shortcode('breadcrumbs', 'avia_breadcrumbs');
with:
/* Breadcrumb shortcode */ function av_breadcrumbs_shortcode( $atts ) { return Avia_Breadcrumb_Trail()->get_trail(array('separator' => '/', 'richsnippet' => true)); } add_shortcode( 'breadcrumbs', 'av_breadcrumbs_shortcode' );
The breadcrumb filters like avia_breadcrumbs_trail still works to modify the structure.
I have tested this on my local server and it does work properly and the Blog next to Home in the breadcrumb is removed in the single posts using the filter you posted.Best regards,
NikkoJune 21, 2021 at 5:33 pm #1306785Thank you Nikko
It works as before, although I still don’t see the schema when I test it.
Please check this link: https://search.google.com/structured-data/testing-tool/u/0/#url=https%3A%2F%2Fwww.insurist.com%2Flife-insurance%2Freviews%2Ffidelity-life%2FWhen I inspect the code I see:
<div class="breadcrumb-trail"><span class="trail-before"><span class="breadcrumb-title">You are here:</span></span> <span><span itemtype="https://schema.org/ListItem" itemprop="itemListElement"><a itemprop="url" href="https://www.insurist.com" title="Insurist" rel="home" class="trail-begin"><span>Home</span></a><span itemprop="position" class="hidden">1</span></span></span> <span class="sep">/</span> <span><span itemtype="https://schema.org/ListItem" itemprop="itemListElement"><a itemprop="url" href="https://www.insurist.com/category/life-insurance/"><span>Life insurance</span></a><span itemprop="position" class="hidden">2</span></span></span> <span class="sep">/</span> <span><span itemtype="https://schema.org/ListItem" itemprop="itemListElement"><a itemprop="url" href="https://www.insurist.com/life-insurance/reviews/"><span>Reviews</span></a><span itemprop="position" class="hidden">3</span></span></span> <span class="sep">/</span> <span class="trail-end">Fidelity Life</span></div>
However, the proper schema for breadcrumbs is:
<ol itemscope itemtype="https://schema.org/BreadcrumbList"> <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"> <a itemprop="item" href="https://example.com/dresses"> <span itemprop="name">Dresses</span></a> <meta itemprop="position" content="1" /> </li> <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"> <a itemprop="item" href="https://example.com/dresses/real"> <span itemprop="name">Real Dresses</span></a> <meta itemprop="position" content="2" /> </li> </ol>
- This reply was modified 3 years, 6 months ago by briangreenberg.
June 23, 2021 at 3:36 pm #1307167Hi Benp,
I apologize for the delayed response.
I see you were referring to the HTML structure, I would suggest you override the avia_breadcrumb_trail class.
Just copy the content in wp-content > themes > enfold > framework > class-breadcrumb-trail.php and paste it in functions.php ( start from class avia_breadcrumb_trail then just exclude the last } ).
Then replace some of the HTML tags with the ones that you’d like to use.
This should break some design in the breadcrumb but you can fix that with CSS.
I would highly suggest using a staging site in order to test this fix first before applying to the live site.Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.