- Wordpress 5.0.1.
- Woocommerce 3.5.2
I am building a Wordpress/Woocommerce based Shop page and want to change the standard woocommerce theme logic especially on the Product Page:
More specifically I want to add a Product Subtitle which should be displayed right after the Product Title. The Product Subtitle should be editable as input field via the standard Woocommerce Product Editor.
To Achieve this i am currently using the "WooCommerce Product Subtitle" Plugin /
Beforehand I have already altered the woocommerce product template hooks so that certain elements on the page are displayed in a different order.
In my functions.php i have written:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'WooCommerce_Product_Subtitle' );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 0 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_price', 2 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_show_product_images', 0 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 1 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 2 );
add_action( 'woocommerce_single_product_summary', 'the_content', 20 );
As i have changed the order of the Product Title:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 0 );
I need the Subtitle to reflect the changes. The problem I have is that the Product Subtitle is not displayed at the position i want it to show. At the moment the subtitle is displayed after the removed product title and not after the newly added one
I don't quite understand how to add_action or remove_action for the Subtitle or where to find the corresponding hooks/actions/classes.
Help would be greatly appreciated!!
- Wordpress 5.0.1.
- Woocommerce 3.5.2
I am building a Wordpress/Woocommerce based Shop page and want to change the standard woocommerce theme logic especially on the Product Page:
More specifically I want to add a Product Subtitle which should be displayed right after the Product Title. The Product Subtitle should be editable as input field via the standard Woocommerce Product Editor.
To Achieve this i am currently using the "WooCommerce Product Subtitle" Plugin https://de.wordpress/plugins/wc-product-subtitle/
Beforehand I have already altered the woocommerce product template hooks so that certain elements on the page are displayed in a different order.
In my functions.php i have written:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'WooCommerce_Product_Subtitle' );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 0 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_price', 2 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_show_product_images', 0 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 1 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 2 );
add_action( 'woocommerce_single_product_summary', 'the_content', 20 );
As i have changed the order of the Product Title:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 0 );
I need the Subtitle to reflect the changes. The problem I have is that the Product Subtitle is not displayed at the position i want it to show. At the moment the subtitle is displayed after the removed product title and not after the newly added one
I don't quite understand how to add_action or remove_action for the Subtitle or where to find the corresponding hooks/actions/classes.
Help would be greatly appreciated!!
Share Improve this question asked Dec 19, 2018 at 11:08 CorinLUSICorinLUSI 231 silver badge8 bronze badges1 Answer
Reset to default 1This is what I have used to show the product category as a subtitle on my shop archive page
add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_shop_loop_item_subtitle', 20 );
function woocommerce_shop_loop_item_subtitle() {
global $post, $product;
$categ = $product->get_categories();
echo $categ;
}
and this is what I used to display it on the single product page
add_action( 'woocommerce_single_product_summary', 'woocommerce_single_item_subtitle', 5 );
function woocommerce_single_item_subtitle() {
global $post, $product;
$categ = $product->get_categories();
?>
<div class="cat-subtitle">
<?php
echo "by " ,$categ;
?>
</div>
<?php
}
You can change what is echoed to output the field you want.