• Resolved drazon

    (@drazon)


    I found on stackoverflow that using the resource attribute can fix this issue.

    For example the unlinked post type template should be

    <span property="itemListElement" typeof="ListItem">
    	<span property="item" typeof="WebPage" resource="%link%">
    		<span property="name">%htitle%</span>
    	</span>	
    	<meta property="position" content="%position%" />
    </span> 
    

    However upon saving the resource attribute gets stripped from the input.

    If you however hardcode it to the output the result passes Google’s structured data test while the html markup also validates at w3c for html5.

    I tried to find more documentation about the resource attribute in the html attributes list however it doesn’t exist.

    What do you guys think?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter drazon

    (@drazon)

    Please note that I’m aware of this solution however the one with the resource attribute results in google recognizing the last item even though it is unlinked

    Plugin Author John Havlik

    (@mtekk)

    Oddly enough, something similar, for a different reason came up recently. Essentially, wp_kses is stripping it out. See https://wordpress.org/support/topic/rdf-schema-markup-for-unlinked-template/#post-11953582 for an outline of how to handle/deal with this. Also see https://mtekk.us/archives/guides/how-to-add-li-and-other-tags-to-breadcrumb-templates/ for an example of using the bcn_allowed_html filter.

    As for Google recognizing the last breadcrumb (the one for the current resource), I’m not sure that matters. The current item, as far as I’m aware, does not show up in the search results listings. Or, is there something I’m missing (very possible)?

    • This reply was modified 4 years, 6 months ago by John Havlik.
    Thread Starter drazon

    (@drazon)

    You are right the resource attribute is not standard and I couldn’t find any related documentation. Also even if Google sees the last breadcrumb, as I tested with other websites it doesn’t show it in the results.

    Creating something like this

    function my_bcn_allowed_html($allowed_html) {
        $allowed_html['span'] = array(
            'title' => true,
            'class' => true,
            'id' => true,
            'dir' => true,
            'align' => true,
            'lang' => true,
            'xml:lang' => true,
            'aria-hidden' => true,
            'data-icon' => true,
            'itemref' => true,
            'itemid' => true,
            'itemprop' => true,
            'itemscope' => true,
            'itemtype' => true,
    	'resource' => true,
    	'property' => true,
    	'typeof' => true
    		
        );
        return $allowed_html;
    }
    add_filter('bcn_allowed_html', 'my_bcn_allowed_html', 10, 1);

    has as a result the %link% to get stripped from the output. Any ideas?

    Plugin Author John Havlik

    (@mtekk)

    I don’t think the %link% gets stripped, it just isn’t replaced by anything useful as currently due to how Breadcrumb NavXT treats unlinked breadcrumbs. This will change in 6.4 (see https://github.com/mtekk/Breadcrumb-NavXT/issues/226 )

    Thread Starter drazon

    (@drazon)

    got it, thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Solution to Missing field “item” for unlinked last item’ is closed to new replies.