2017-10-24 4 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를 두 번 설정하는 다음 코드는 올바르지 않습니다. 다음과 같이

<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"> 

동일

<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"> 

이와 관련된 오차가 나중에 동일한 실수로 발생되어야 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="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">