• Hi,

    I want to be able to add the following breadcrumb markup:

    
    <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
    <a itemprop="item" typeof="WebPage" href="%link%" class="%type%">
    <span itemprop="name">Home</span></a>
    <meta itemprop="position" content="%position%">
    </li>
    

    However, when I try to save it, it strips out all the attributes in the li tag and says “Settings did not change, nothing to save.”

    Without this the Google Structured Data Testing Tool shows errors.

    Please help.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter JamesKoussertari

    (@jameskoussertari)

    .

    Plugin Author John Havlik

    (@mtekk)

    The default settings for Breadcrumb NavXT are schema.org BreadcrumbList compliant, you shouldn’t need to modify them. That said, if you want to use li wrappers, it is probably better to use bcn_display_list rather than bcn_display.

    The reason the setting won’t save is likely due to something in the li element not being whitelisted when it is run through wp_kses. You can add support for this element and various attributes by writing a filter for the bcn_allowed_html hook. See https://mtekk.us/archives/guides/how-to-add-li-and-other-tags-to-breadcrumb-templates/ for an example of how to do this.

    Thread Starter JamesKoussertari

    (@jameskoussertari)

    Hi, Thanks for your reply.

    Perhaps I’m doing something wrong, but your plugin does not include either of these lines of code in the output by default:

    RDFa

    
    <ol vocab="https://schema.org/" typeof="BreadcrumbList">
      <li property="itemListElement" typeof="ListItem">
    

    I’m having to wrap bcn_display() in an <ol> with the schema code like so:

    
    <ol class="breadcrumbs mb50" vocab="https://schema.org/" typeof="BreadcrumbList">
       <?php bcn_display($return = false, $linked = true, $reverse = false, $force = false); ?>
    </ol>
    

    But Google is still saying this:
    A value for the itemListElement field is required.

    So I guess if I could add something to stop stripping out the <li> attributes that would solve all my problems. I just don’t know exactly how I would go about adding a filter to stop stripping out the following code:

    <li property="itemListElement" typeof="ListItem">

    Can you help me with this please?

    Thanks

    Thread Starter JamesKoussertari

    (@jameskoussertari)

    Don’t worry this sorted it, like you previously suggested:

    
    /* Allow extra tags in <li> */
    function scratch_bcn_allowed_html($allowed_html){
        $allowed_html['li'] = array(
    		'property' => true,
    		'typeof' => true
    		
        );
        return $allowed_html;
    }
    add_filter('bcn_allowed_html', 'scratch_bcn_allowed_html');
    

    I am then using this for all linked breadcrumbs:

    
    <li property="itemListElement" typeof="ListItem">
    <a property="item" typeof="WebPage" href="%link%" class="%type%">
    <span property="name">Home</span>
    </a>
    <meta property="position" content="%position%">
    </li>
    

    And this for all unlinked:

    
    <li>
    <span>%htitle%</span>
    <meta content="%position%">
    </li>
    

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘itemprop=”itemListElement”’ is closed to new replies.