Schema.org 菜单类型 属性 hasMenuSection & hasMenuItem
Schema.org Menu type property hasMenuSection & hasMenuItem
我正在尝试在 schema.org 中创建一个菜单,但不知何故它无效。这与属性 hasMenuSection 和 hasMenuItem 有关。我在这段代码中做错了什么?
<div itemscope itemtype="http://schema.org/Menu" itemref="restaurant-info-footer">
<meta itemprop="url" content="<?php the_permalink(); ?>">
<meta itemprop="mainEntityOfPage" content="<?php the_permalink(); ?>">
<meta itemprop="inLanguage" content="<?php echo get_locale(); ?>">
<h2 itemprop="name"><?php echo get_the_title( $menu_id ); ?></h2>
<?php if ( ! empty( $menu_price ) && ! is_null( $menu_price ) && $hide_prices ) : ?>
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<meta itemprop="price" content="<?php echo number_format( $menu_price, 2, ',', '.'); ?>">
<meta itemprop="priceCurrency" content="EUR">
</span>
<?php endif; ?>
<div class="courses" itemscope itemprop="hasMenuSection" itemtype="http://schema.org/hasMenuSection">
<?php foreach ( $courses as $course ) : ?>
<div class="course" itemscope itemprop="MenuSection" itemtype="http://schema.org/MenuSection">
<div class="course-holder" style="background-image: url(<?php echo $course['image']; ?>);">
<h3 itemprop="name"><?php echo $course['name']; ?></h3>
</div>
<div class="course-dishes" itemscope itemprop="hasMenuItem" itemtype="http://schema.org/hasMenuItem">
<?php foreach ( $course['dishes'] as $dish ) : ?>
<?php $dish = $dish['dish']; ?>
<div class="dish" itemscope itemprop="MenuItem" itemtype="http://schema.org/MenuItem">
<h4 itemprop="name"><?php echo get_the_title( $dish ); ?></h4>
<?php if ( ! empty( get_field( 'more-price', $dish ) ) && ! is_null( get_field( 'more-price', $dish ) ) && ! $hide_prices ) : ?>
<span class="more-price">(<?php _e( 'addition', 'croy-plugin' ); ?> <?php the_field( 'more-price', $dish ); ?>)</span>
<?php endif; ?>
<?php if ( get_field( 'vegan', $dish ) ) : ?>
<span class="vegan" itemprop="suitableForDiet" content="http://schema.org/VeganDiet"></span>
<?php endif; ?>
<p itemprop="description"><?php the_field( 'subtitel', $dish ); ?></p>
<?php if ( ! empty( get_field( 'price', $dish ) ) && ! is_null( get_field( 'price', $dish ) ) && ! $hide_prices ) : ?>
<div class="price" itemprop="offers" itemtype="http://schema.org/offers" itemscope>
<p itemprop="price"><?php echo number_format( get_field( 'price', $dish ), 2, ',', '.' ); ?></p>
<meta itemprop="priceCurrency" content="EUR">
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
调试器报错如下:
hasMenuSection is not a valid target type for the property hasMenuSection.
hasMenuItem is not a valid target type for the property hasMenuItem.
虽然 Offers 和 MenuItem 都不错。
有什么建议吗?
hasMenuSection 是 属性,不是类型。因此,以下代码设置了两次 itemscope,一次用于 hasMenuSection(不是一种类型),一次用于 MenuSection,它不是 属性,是不正确的。
<div class="courses" itemscope itemprop="hasMenuSection" itemtype="http://schema.org/hasMenuSection">
<?php foreach ( $courses as $course ) : ?>
<div class="course" itemscope itemprop="MenuSection" itemtype="http://schema.org/MenuSection">
代码应该如下。 itemscope
用于声明新范围一次。 itemprop
指的是 属性 名称。 itemtype
指的是里面包含的类型。
<div class="courses">
<?php foreach ( $courses as $course ) : ?>
<div class="course" itemscope itemprop="hasMenuSection" itemtype="http://schema.org/MenuSection">
同样适用于hasMenuItem
<div class="course-dishes" itemscope itemprop="hasMenuItem" itemtype="http://schema.org/hasMenuItem">
<?php foreach ( $course['dishes'] as $dish ) : ?>
<?php $dish = $dish['dish']; ?>
<div class="dish" itemscope itemprop="MenuItem" itemtype="http://schema.org/MenuItem">
应该是
<div class="course-dishes">
<?php foreach ( $course['dishes'] as $dish ) : ?>
<?php $dish = $dish['dish']; ?>
<div class="dish" itemscope itemprop="hasMenuItem" itemtype="http://schema.org/MenuItem">
后面的相关错误是类似的错误引起的
<div class="price" itemprop="offers" itemtype="http://schema.org/offers" itemscope>
优惠不是一种类型,它是 属性。 itemprop="offers"
声明 属性 是正确的,但 itemtype 应该是 Offer,而不是不存在的商品。以上将为您带来以下错误:
offers is not a known valid target type for the offers property.
所以应该是
<div class="price" itemscope itemprop="offers" itemtype="http://schema.org/Offer">
我正在尝试在 schema.org 中创建一个菜单,但不知何故它无效。这与属性 hasMenuSection 和 hasMenuItem 有关。我在这段代码中做错了什么?
<div itemscope itemtype="http://schema.org/Menu" itemref="restaurant-info-footer">
<meta itemprop="url" content="<?php the_permalink(); ?>">
<meta itemprop="mainEntityOfPage" content="<?php the_permalink(); ?>">
<meta itemprop="inLanguage" content="<?php echo get_locale(); ?>">
<h2 itemprop="name"><?php echo get_the_title( $menu_id ); ?></h2>
<?php if ( ! empty( $menu_price ) && ! is_null( $menu_price ) && $hide_prices ) : ?>
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<meta itemprop="price" content="<?php echo number_format( $menu_price, 2, ',', '.'); ?>">
<meta itemprop="priceCurrency" content="EUR">
</span>
<?php endif; ?>
<div class="courses" itemscope itemprop="hasMenuSection" itemtype="http://schema.org/hasMenuSection">
<?php foreach ( $courses as $course ) : ?>
<div class="course" itemscope itemprop="MenuSection" itemtype="http://schema.org/MenuSection">
<div class="course-holder" style="background-image: url(<?php echo $course['image']; ?>);">
<h3 itemprop="name"><?php echo $course['name']; ?></h3>
</div>
<div class="course-dishes" itemscope itemprop="hasMenuItem" itemtype="http://schema.org/hasMenuItem">
<?php foreach ( $course['dishes'] as $dish ) : ?>
<?php $dish = $dish['dish']; ?>
<div class="dish" itemscope itemprop="MenuItem" itemtype="http://schema.org/MenuItem">
<h4 itemprop="name"><?php echo get_the_title( $dish ); ?></h4>
<?php if ( ! empty( get_field( 'more-price', $dish ) ) && ! is_null( get_field( 'more-price', $dish ) ) && ! $hide_prices ) : ?>
<span class="more-price">(<?php _e( 'addition', 'croy-plugin' ); ?> <?php the_field( 'more-price', $dish ); ?>)</span>
<?php endif; ?>
<?php if ( get_field( 'vegan', $dish ) ) : ?>
<span class="vegan" itemprop="suitableForDiet" content="http://schema.org/VeganDiet"></span>
<?php endif; ?>
<p itemprop="description"><?php the_field( 'subtitel', $dish ); ?></p>
<?php if ( ! empty( get_field( 'price', $dish ) ) && ! is_null( get_field( 'price', $dish ) ) && ! $hide_prices ) : ?>
<div class="price" itemprop="offers" itemtype="http://schema.org/offers" itemscope>
<p itemprop="price"><?php echo number_format( get_field( 'price', $dish ), 2, ',', '.' ); ?></p>
<meta itemprop="priceCurrency" content="EUR">
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
调试器报错如下:
hasMenuSection is not a valid target type for the property hasMenuSection.
hasMenuItem is not a valid target type for the property hasMenuItem.
虽然 Offers 和 MenuItem 都不错。
有什么建议吗?
hasMenuSection 是 属性,不是类型。因此,以下代码设置了两次 itemscope,一次用于 hasMenuSection(不是一种类型),一次用于 MenuSection,它不是 属性,是不正确的。
<div class="courses" itemscope itemprop="hasMenuSection" itemtype="http://schema.org/hasMenuSection"> <?php foreach ( $courses as $course ) : ?> <div class="course" itemscope itemprop="MenuSection" itemtype="http://schema.org/MenuSection">
代码应该如下。 itemscope
用于声明新范围一次。 itemprop
指的是 属性 名称。 itemtype
指的是里面包含的类型。
<div class="courses">
<?php foreach ( $courses as $course ) : ?>
<div class="course" itemscope itemprop="hasMenuSection" itemtype="http://schema.org/MenuSection">
同样适用于hasMenuItem
<div class="course-dishes" itemscope itemprop="hasMenuItem" itemtype="http://schema.org/hasMenuItem"> <?php foreach ( $course['dishes'] as $dish ) : ?> <?php $dish = $dish['dish']; ?> <div class="dish" itemscope itemprop="MenuItem" itemtype="http://schema.org/MenuItem">
应该是
<div class="course-dishes">
<?php foreach ( $course['dishes'] as $dish ) : ?>
<?php $dish = $dish['dish']; ?>
<div class="dish" itemscope itemprop="hasMenuItem" itemtype="http://schema.org/MenuItem">
后面的相关错误是类似的错误引起的
<div class="price" itemprop="offers" itemtype="http://schema.org/offers" itemscope>
优惠不是一种类型,它是 属性。 itemprop="offers"
声明 属性 是正确的,但 itemtype 应该是 Offer,而不是不存在的商品。以上将为您带来以下错误:
offers is not a known valid target type for the offers property.
所以应该是
<div class="price" itemscope itemprop="offers" itemtype="http://schema.org/Offer">