Last active
August 29, 2015 14:01
-
-
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
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 | |
| // 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