Skip to content

Instantly share code, notes, and snippets.

@NicBeltramelli
Created February 14, 2019 09:43
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 NicBeltramelli/e3c43ae2a8ebc6e06a37e9e088a0a223 to your computer and use it in GitHub Desktop.
Save NicBeltramelli/e3c43ae2a8ebc6e06a37e9e088a0a223 to your computer and use it in GitHub Desktop.
Customize the Genesis post meta function for post and WooCommerce product post types
<?php
// Do NOT include the opening php tag.
/**
* Customize the post meta function
*
* @author Nic Beltramelli
*
* @param array $post_meta Default post meta fields.
* @return array Custom post meta fields.
*/
add_filter(
'genesis_post_meta', function ( $post_meta ) {
if ( 'post' == get_post_type() ) :
$post_meta = '[post_categories before="" sep="&nbsp;|"] [post_tags before="" sep="&nbsp;|"] ';
elseif ( 'product' == get_post_type() ) :
$post_meta = '[post_terms taxonomy="product_cat" before="" sep="&nbsp;|"] [post_terms taxonomy="product_tag" before="" sep="&nbsp;|"]';
endif;
return $post_meta;
}, 11
);
/* Add Genesis post meta to WooCommerce product single */
add_action( 'woocommerce_product_meta_end', 'genesis_post_meta' );
/* Hide default WooCommerce product meta categories & tags */
.woocommerce div.product .product_meta > span.posted_in,
.woocommerce div.product .product_meta > span.tagged_as {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment