Created
September 22, 2024 02:32
-
-
Save askwpgirl/4ae642a5533145931ba3990d0cbfd6ef to your computer and use it in GitHub Desktop.
WooCommerce - Add Short Description to Product Archives
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 | |
// Add the following to Code Snippets after creating ACF Field for the short description | |
// apply the ACF field group to Products posts | |
/*-------------------------------------------------------*/ | |
/* Add short description to product archives | |
/*-------------------------------------------------------*/ | |
function my_excerpt_in_product_archives() { | |
echo '<span class="product_excerpt">'; | |
if( get_field('my_short_description') ): | |
echo the_field('my_short_description'); | |
else : | |
the_excerpt(); | |
endif; | |
echo '</span>'; | |
} | |
add_action( 'woocommerce_after_shop_loop_item_title', 'my_excerpt_in_product_archives', 40 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment