Skip to content

Instantly share code, notes, and snippets.

@aj-adl
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save aj-adl/1a89da217645855035b1 to your computer and use it in GitHub Desktop.

Select an option

Save aj-adl/1a89da217645855035b1 to your computer and use it in GitHub Desktop.
Display an ACF field below the product tile in the WooCommerce product loop
<?php
// don't include this opening PHP tag if you're copying this into your functions.php file etc
/**
* Renders a Product Subtitle
*
* Can change the html/classes etc as much as you want
*
* Requires Advanced Custom Fields to work
*/
function ttd_product_subtitle(){
$subtitle = get_field('YOUR_FIELD_NAME_HERE');
if ( $subtitle ) {
echo '<div class="subtitle">';
echo '<p>'.$subtitle.'</p>';
echo '</div>';
}
}
/**
* Hooking it up to the revlevant action
*
* If prioroty (the number) is lower than 5 it will appear above the ratings and price
*/
add_action( 'woocommerce_after_shop_loop_item_title', 'ttd_product_subtitle', 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment