Created
February 14, 2019 09:43
-
-
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
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 | |
// 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=" |"] [post_tags before="" sep=" |"] '; | |
elseif ( 'product' == get_post_type() ) : | |
$post_meta = '[post_terms taxonomy="product_cat" before="" sep=" |"] [post_terms taxonomy="product_tag" before="" sep=" |"]'; | |
endif; | |
return $post_meta; | |
}, 11 | |
); | |
/* Add Genesis post meta to WooCommerce product single */ | |
add_action( 'woocommerce_product_meta_end', 'genesis_post_meta' ); |
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
/* 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