This file contains hidden or 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" /> |
This file contains hidden or 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
// If you want to remove the categories with ids 10, 12, 14 and 16 from the Category Mapping, including their children categories, | |
// you could use the following code in your functions.php file | |
// hook the remove_cats function to the wppfm_category_mapping_exclude_tree event | |
add_filter( 'wppfm_category_mapping_exclude_tree', 'remove_cats' ); | |
function remove_cats() { | |
// return a comma separated string or an array with the category ids you want to exclude | |
return "10,12,14,16"; | |
} |
This file contains hidden or 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
function alter_feed_item( $attributes, $feed_id, $product_id ) { | |
//global $product; | |
$product = wc_get_product( $product_id ); | |
$featured_image_ids[0] = get_post_thumbnail_id( $product_id ); | |
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id($featured_image_ids[0]), 'full'); | |
if($featured_image) { | |
$attributes['image_link'] = $featured_image[0]; | |
} |
This file contains hidden or 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
/** | |
* Alter Product feed item | |
* Make the title attribute lowercase | |
*/ | |
function alter_feed_item( $attributes, $feed_id, $product_id ) { | |
// lowercase | |
$title = $attributes['title']; | |
$title = strtolower($title); //make lower case | |
$title = ucfirst($title) // maken first character capitalized |
This file contains hidden or 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 | |
// wppfm feed ides in queue Filter | |
// | |
function only_last_week_ids( $ids ) { | |
$index = 0; // set the index | |
foreach( $ids as $id ) { | |
$post_date = get_the_date( 'U', $id ); // get the posts published date |
This file contains hidden or 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 | |
/** | |
* Alter Product feed item | |
* Uppercase a source value (attribute_pa_cup) and combine with an other source value in the size attribute | |
*/ | |
function alter_feed_item( $attributes, $feed_id, $product_id ) { | |
// get values | |
$attribute_pa_band = $attributes['custom_label_0']; //add the attribute_pa_band to attribute "custom_label_0" |
This file contains hidden or 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 | |
function alter_feed_item( $attributes, $feed_id, $product_id ) { | |
// In this example I have added the "custom_label_0" to each feed. | |
// Custom_label_0 is filled with a ISO currency code as a static value | |
// Forinstance the ISO currency code for the US is USD. | |
// uses wmc_get_price() from woocomerce multiple currencies | |
//get the correct price in the correct currency. |
This file contains hidden or 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 | |
function alter_feed_price_item_remove_thousand_seperator( $attributes, $feed_id, $product_id ) { | |
global $product; | |
$product = wc_get_product( $product_id ); | |
$product_price = $attributes['price']; | |
// show price without thousand separator and . as decimal separator | |
$attributes['price'] = number_format( $product_price, 2, '.', '') . " EUR"; | |
// price will look like 1234.57 |
This file contains hidden or 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 | |
// Locate the file header.php in your theme | |
// Before editing header.php, always make a backup so that you can roll back if something goes wrong. | |
// At the bottom of the header, simple add the code below | |
// Verify that you have done it correctly by checking the page with Google’s Structured Data Testing Tool | |
// https://search.google.com/structured-data/testing-tool | |
if (isset($product)){ | |
$meta = get_post_meta(get_the_ID()); | |
$_product = new WC_Product(get_the_ID()); | |
if ($_product->regular_price!=NULL){ |
This file contains hidden or 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
function expand_cdata_attributes( $cdata_attributes ) { | |
// price and availability attributes are added to the list of attributes that are included in a CDATA bracket | |
array_push( $cdata_attributes, 'price', 'availability' ); | |
return $cdata_attributes; | |
} | |
add_filter( 'wppfm_cdata_keys', 'expand_cdata_attributes' ); |