如何让定制的帖子类型与schema.org很好地配合(也就是如何包装schema.org标记中的内容)?

时间:2011-11-17 作者:Hagbard Celine

建立一个烹饪网站,用一个自定义的帖子类型,比如“Recipes”。我正准备将上述帖子类型的内容打包schema.org\'s recipe microformat.

我如何做到这一点?

1 个回复
SO网友:Scott

该链接为您提供了HTML示例:

<div itemscope itemtype="http://schema.org/Recipe">
  <span itemprop="name">Mom\'s World Famous Banana Bread</span>
  By <span itemprop="author">John Smith</span>,
  <meta itemprop="datePublished" content="2009-05-08">May 8, 2009
  <img itemprop="image" src="bananabread.jpg" />

  <span itemprop="description">This classic banana bread recipe comes
  from my mom -- the walnuts add a nice texture and flavor to the banana
  bread.</span>

  Prep Time: <meta itemprop="prepTime" content="PT15M">15 minutes
  Cook time: <meta itemprop="cookTime" content="PT1H">1 hour
  Yield: <span itemprop="recipeYield">1 loaf</span>

  <div itemprop="nutrition"
    itemscope itemtype="http://schema.org/NutritionInformation">
    Nutrition facts:
    <span itemprop="calories">240 calories</span>,
    <span itemprop="fatContent">9 grams fat</span>
  </div>

  Ingredients:
  - <span itemprop="ingredients">3 or 4 ripe bananas, smashed</span>
  - <span itemprop="ingredients">1 egg</span>
  - <span itemprop="ingredients">3/4 cup of sugar</span>
  ...

  Instructions:
  <span itemprop="recipeInstructions">
  Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add
  the flour last. Pour the mixture into a loaf pan and bake for one hour.
  </span>

  140 comments:
  <meta itemprop="interactionCount" content="UserComments:140" />
  From Janel, May 5 -- thank you, great recipe!
  ...
</div>
您需要做的是创建元字段来收集每个帖子/食谱的附加信息。

然后创建一个模板,在类似于上面的模板中显示此信息。您可以使用single-{CPT\\u Slug}。CPT/配方页面的php文件。

自定义字段信息:http://codex.wordpress.org/Custom_Fields

结束

相关推荐