$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>theme development - How to show Custom Field Value in Woocommerce Shop Page|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

theme development - How to show Custom Field Value in Woocommerce Shop Page

matteradmin9PV0评论
remove_action('woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title',10);
add_action('woocommerce_shop_loop_item_title','fun',10);
function fun()
{

echo 'custom_field_value';

}

Note: I want to replace the title on shop page with custom field value. The code is correct but the echo part I need help on it.

remove_action('woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title',10);
add_action('woocommerce_shop_loop_item_title','fun',10);
function fun()
{

echo 'custom_field_value';

}

Note: I want to replace the title on shop page with custom field value. The code is correct but the echo part I need help on it.

Share Improve this question edited Dec 11, 2018 at 10:17 Pratik Patel 1,1091 gold badge11 silver badges23 bronze badges asked Dec 11, 2018 at 3:25 Joseph PausalJoseph Pausal 1 1
  • try this code :if (is_shop()){ echo 'custom_field_value'; } – vikrant zilpe Commented Dec 11, 2018 at 14:15
Add a comment  | 

2 Answers 2

Reset to default 0

woocommerce_shop_loop_item_title is not the right hook to change the title on shop page.

Try this instead:

add_filter( 'woocommerce_page_title', function() {
    echo 'custom_field_value';
} );

I need help on this section only since the code I have provided is 100% working to remove the title.

echo 'custom_field_value';

If I will call custom field as custom_title how can I show this?

Post a comment

comment list (0)

  1. No comments so far