Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action ('woocommerce_product_options_general_product_data', 'subtitle_product_data_metabox');
- function subtitle_product_data_metabox() {
- echo '<div class="options_group">';
- woocommerce_wp_text_input (array (
- 'id' => 'product_subtitle_inside_loop',
- 'value' => get_post_meta (get_the_ID(), 'product_subtitle_inside_loop', true),
- 'label' => 'Product subtitle',
- 'description' => 'Subtitle text to appear between title and price'
- ));
- echo '</div>';
- }
- add_action ('woocommerce_process_product_meta', 'save_subtitle_field_on_update', 10, 2);
- function save_subtitle_field_on_update ($id, $post) {
- update_post_meta ($id, 'product_subtitle_inside_loop', $_POST['product_subtitle_inside_loop']);
- }
- add_action( 'woocommerce_after_shop_loop_item_title', 'show_subtitle_after_shop_loop_item_title', 1, 0 );
- function show_subtitle_after_shop_loop_item_title() {
- global $product;
- $product_subtitle_inside_loop = $product->get_meta ('product_subtitle_inside_loop');
- echo $product_subtitle_inside_loop;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement