Php 更改WooCommerce通知在店面主题中的位置

Php 更改WooCommerce通知在店面主题中的位置,php,wordpress,woocommerce,notice,storefront,Php,Wordpress,Woocommerce,Notice,Storefront,我正在尝试更改店面(WooCommerce)子主题中店面(shop)消息的位置。因此,我在活动主题的functions.php中添加了以下代码: remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 ); add_action('woocommerce_product_meta_end', 'storefront_shop_messages', 1 ); 但它不起作用。在评论中获得您期望的内容的正确方法(

我正在尝试更改店面(WooCommerce)子主题中店面(shop)消息的位置。因此,我在活动主题的functions.php中添加了以下代码:

remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
add_action('woocommerce_product_meta_end', 'storefront_shop_messages', 1 );

但它不起作用。

在评论中获得您期望的内容的正确方法(意味着仅在产品单页上的“添加到购物车”按钮后显示WooCommerce通知):

代码位于活动子主题(或主题)的function.php文件或任何插件文件中


使用WooCommerce 3.1+

对店面主题进行测试和工作。好的,你能想到一个更通用的钩子吗?特别是,您能否建议如何仅在单个产品页面上移动这些消息?那么,将店面中的警告消息移动到产品页面的“添加到购物车”按钮下方的最佳方法是什么?抱歉@LoicTheAztec,我被问题/答案搞混了;)非常感谢你的帮助!虽然这段代码出现了一个奇怪的php错误:警告:call_user_func_array()希望参数1是一个有效的回调,在第298行的/home/hugomatha/hemen.makemy.biz/wp-includes/class-wp-hook.php中找不到函数'woomerce_\u before_main_content',或者函数名无效,所以我使用了而不是
add_action('woocommerce\u single\u product\u summary'、'woocommerce\u before\u main\u content',34);
我用了这行:
添加动作('woocommerce\u product\u meta\u end'、'storefront\u shop\u messages',1);
add_action( 'wp_head', 'customize_notices' );
function customize_notices(){
    if( is_product() )
        remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
    remove_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
    add_action( 'woocommerce_single_product_summary', 'woocommerce_before_main_content', 34 );
}