• Hi, you’ve saved me from terrible things. I was stymied by Woocommerce’s lack of duplicate slugs in categories. My work around was to use Permalinks Customizer and tags. All was well but I couldn’t find a breadcumbs that worked with this method of creating permalinks.
    Yours did with a this in my functions:

    
    # Add a new page item and its ancestry
    add_action('carbon_breadcrumbs_after_setup_trail', 'crb_add_test_page_item');
    
    function crb_add_test_page_item($trail)
    	{
    	if (is_product())
    		{
    		$terms = get_the_terms($post->ID, 'product_tag');
    		foreach($terms as $term)
    			{
    			if ($term->slug == 't4-76-1st')
    				{
    				$locator = Carbon_Breadcrumb_Locator::factory('post', 'page');
    				$priority = 500;
    				$page_id = 1497;
    				$items = $locator->get_items($priority, $page_id);
    				if ($items)
    					{
    					$trail->add_item($items);
    					}
    				}
                if ($term->slug == 't4-35-1st')
    				{
    				$locator = Carbon_Breadcrumb_Locator::factory('post', 'page');
    				$priority = 500;
    				$page_id = 1496;
    				$items = $locator->get_items($priority, $page_id);
    				if ($items)
    					{
    					$trail->add_item($items);
    					}
    				}
                if ($term->slug == 't2-76-1st')
    				{
    				$locator = Carbon_Breadcrumb_Locator::factory('post', 'page');
    				$priority = 500;
    				$page_id = 1499;
    				$items = $locator->get_items($priority, $page_id);
    				if ($items)
    					{
    					$trail->add_item($items);
    					}
    				}
                if ($term->slug == 't2-35-1st')
    				{
    				$locator = Carbon_Breadcrumb_Locator::factory('post', 'page');
    				$priority = 500;
    				$page_id = 1498;
    				$items = $locator->get_items($priority, $page_id);
    				if ($items)
    					{
    					$trail->add_item($items);
    					}
    				}
    			}
    		}
    	}
    
    

    Marvellous! Thank you ??

    However…
    I can’t seem to make schema.org attributes work.
    For example, I have ol vocab=”https://schema.org/&#8221; typeof=”BreadcrumbList” in my ‘wrapper before’ in the ‘general settings’ page. But, I’m just seeing ol and no attributes. It’s the same with ‘title before’ <span property=”name”> coming out as just <span>.

    Also, I’m trying to add attributes to each link in the breadcrumbs, also in my functions.php

    
    add_action('carbon_breadcrumbs_item_attributes', 'crb_carbon_breadcrumbs_item_attributes');
    function crb_carbon_breadcrumbs_item_attributes($attributes) {
        $attributes = array(
        'target' => '_blank',
        'property' => 'item',
        'typeof' => 'WebPage',
        'class' => 'foobartwo'
    	);
        return $attributes;
    }
    

    The ‘target’ attribute will change, as will class, but I’m not adding my property nor my typeof. This is probably because I’m an idiot.

    Hope you can help,
    Be happy for ever,
    Steve

    • This topic was modified 8 years, 3 months ago by stevehoo.
    • This topic was modified 8 years, 3 months ago by stevehoo.
    • This topic was modified 8 years, 3 months ago by stevehoo.
    • This topic was modified 8 years, 3 months ago by stevehoo.
Viewing 1 replies (of 1 total)
  • Thread Starter stevehoo

    (@stevehoo)

    Finally, I’ve found that some attributes within tags are not explicitly allowed. By adding this to my functions.php, all is now well.

    add_filter( 'wp_kses_allowed_html', function ( $allowedposttags, $context ) {
        if ( $context == 'post' ) {
            $allowedposttags['ol']['typeof'] = 1;
            $allowedposttags['ol']['vocab'] = 1;
            $allowedposttags['span']['property'] = 1;
            $allowedposttags['li']['property'] = 1;
            $allowedposttags['li']['typeof'] = 1;
            $allowedposttags['a']['property'] = 1;
            $allowedposttags['a']['typeof'] = 1;
        }
        return $allowedposttags;
    }, 10, 2 );

    As per the full structured RDFa. I’m getting a clear pass with Google’s testing tool.

    I would like to complete the RDFa with meta tags, but as yet I don’t know how to add these to Carbon breadcrumbs.
    <meta property="position" content="1">

    And if I could add the last anchor to be typeOf = ‘product’ instead of my global set in my functions.php typeOf = ‘webPage.’ That would be complete. (Left for another day.)

    Great plugin ??

    Be happy for ever,
    Steve

    • This reply was modified 7 years, 10 months ago by stevehoo. Reason: Further info
    • This reply was modified 7 years, 10 months ago by stevehoo.
Viewing 1 replies (of 1 total)
  • The topic ‘schema.org attributes’ is closed to new replies.