Skip to content

Instantly share code, notes, and snippets.

@seb86
Created June 7, 2013 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seb86/5730383 to your computer and use it in GitHub Desktop.
Save seb86/5730383 to your computer and use it in GitHub Desktop.
New template file for single-product in WooCommerce. schema.php
<?php
/**
* Identifies the product type and outputs the
* correct Schema for the beginning of the
* product container.
*
* @author: Seb's Studio
* @package WooCommerce/Templates
* @version 2.1
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $post, $product;
/* If the product is not downloadable. */
if(!$product->is_downloadable()){
?>
<div itemscope itemtype="http://schema.org/Product" id="product-<?php echo $post->ID; ?>" <?php post_class(); ?>>
<?php
}
/* If the product is downloadable, what type of downloadable product is it. */
else{
if(get_post_meta($post->ID, '_download_type', true) == 'application'){
?>
<div itemscope itemtype="http://schema.org/SoftwareApplication" id="product-<?php echo $post->ID; ?>" <?php post_class(); ?>>
<?php
}
else if(get_post_meta($post->ID, '_download_type', true) == 'music'){
?>
<div itemscope itemtype="http://schema.org/MusicAlbum" id="product-<?php echo $post->ID; ?>" <?php post_class(); ?>>
<?php
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment