2017-10-24 3 views
0

schema.orgでメニューを作成しようとしていますが、何とか有効ではありません。これはプロパティ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> 
デバッガは次のエラーを通知します

:オファーとのMenuItemが良いですが

hasMenuSection is not a valid target type for the property hasMenuSection.

hasMenuItem is not a valid target type for the property hasMenuItem.

提案がありますか?

答えて

3

hasMenuSectionはタイプではなくプロパティです。したがって、hasMenuSection(型ではない)とMenuSection(プロパティではない)のために一度、itemscopeを2回設定する次のコードは正しくありません。

<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は、新しいスコープを宣言するために1回使用されます。 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"> 
次のようになります。上記のあなたの次のエラーを取得します
関連する問題