Created
February 15, 2018 10:35
-
-
Save Auke1810/c92f66e6870b58cfe3e51349a59a9c54 to your computer and use it in GitHub Desktop.
Easily add the correct structured data using Microdata for Google Merchant, this includes the missing microdata for condition. At the bottom of the header simple add the code below
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $meta = get_post_meta(get_the_ID());?> | |
<?php if (isset($product)){ ?> | |
<div itemscope itemtype="http://schema.org/Product"> | |
<meta itemprop="name" content="<?php echo get_the_title(get_the_ID()); ?>"> | |
<meta itemprop="productID" content="<?php echo get_the_ID(); ?>"> | |
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer"> | |
<meta itemprop="price" content="<?php echo get_post_meta( get_the_ID(), '_regular_price', true); ?>" /> | |
<meta itemprop="priceCurrency" content="<?php echo get_woocommerce_currency(); ?>" /> | |
<link itemprop="availability" href="http://schema.org/<?php echo $meta['_stock_status'][0] ? 'InStock' : 'OutOfStock'; ?>" /> | |
<meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition" /> | |
</div> | |
</div> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment