Skip to content

Отсутствует поле "item" - ошибка в Гугл вебмастере

Всем привет, может поможет кто разобраться. Ругается на цепочку крошек, может я упустил что-то из виду.

Ругается вот на этот кусок кода:

<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem" class="trail-item trail-begin"><a href="https://site.ru" rel="home"><span itemprop="name">Главная</span></a><meta itemprop="position" content="1" /></li>


Код в шаблоне такой:

// Open the unordered list.
$breadcrumb .= '<ul class="trail-items" itemscope itemtype="http://schema.org/BreadcrumbList">';

// Add the number of items and item list order schema.
$breadcrumb .= sprintf( '<meta name="numberOfItems" content="%d" />', absint( $item_count ) );
$breadcrumb .= '<meta name="itemListOrder" content="Ascending" />';

// Loop through the items and add them to the list.
foreach ( $this->items as $item ) {

    // Iterate the item position.
    ++$item_position;

    // Check if the item is linked.
    preg_match( '/(<a.*?>)(.*?)(<\/a>)/i', $item, $matches );

    // Wrap the item text with appropriate itemprop.
    $item = !empty( $matches ) ? sprintf( '%s<span itemprop="name">%s</span>%s', $matches[1], $matches[2], $matches[3] ) : sprintf( '<span itemprop="name">%s</span>', $item );

    // Add list item classes.
    $item_class = 'trail-item';

    if ( 1 === $item_position && 1 < $item_count )
        $item_class .= ' trail-begin';

    elseif ( $item_count === $item_position )
        $item_class .= ' trail-end';

    // Create list item attributes.
    $attributes = 'itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem" class="' . $item_class . '"';

    // Build the meta position HTML.
    $meta = sprintf( '<meta itemprop="position" content="%s" />', absint( $item_position ) );

    // Build the list item.
    $breadcrumb .= sprintf( '<li %s>%s%s</li>', $attributes, $item, $meta );
    }

// Close the unordered list.
$breadcrumb .= '</ul>';


Помогите разобраться где что поправить?

Edited by Lesovsky
Используйте специальный бб-код для вставки фрагментов кода!

Featured Replies

https://developers.google.com/search/docs/data-types/breadcrumb

      <li itemprop="itemListElement" itemscope
          itemtype="https://schema.org/ListItem">
        <a itemprop="item" href="https://example.com/books">
            <span itemprop="name">Books</span></a>
        <meta itemprop="position" content="1" />
      </li>

У ссылки есть атрибут itemprop со значением item

  • Author
8 часов назад, newbie сказал:

https://developers.google.com/search/docs/data-types/breadcrumb


      <li itemprop="itemListElement" itemscope
          itemtype="https://schema.org/ListItem">
        <a itemprop="item" href="https://example.com/books">
            <span itemprop="name">Books</span></a>
        <meta itemprop="position" content="1" />
      </li>

У ссылки есть атрибут itemprop со значением item

поправил и добавил itemprop="item", но все равно пишет что ошибка

image.thumb.png.a0073969dd3564ca87b5c77e19b924db.png

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.