2017-11-01 9 views
0

店頭ホームページのアクション間に自分のコードを並べ替えて追加したいと思います。私はアクションを追加/並べ替える方法を知っていますが、自分のコードを追加する方法はわかりません。woocomerce + storefront - ホームページのフック/アクション間にカスタムフィールドを追加する

function storefront_child_reorder_homepage_contant() { 
    remove_action('homepage', 'storefront_homepage_content', 10); 
    remove_action('homepage', 'storefront_product_categories', 20); 
    remove_action('homepage', 'storefront_recent_products', 30); 
    remove_action('homepage', 'storefront_featured_products', 40); 
    remove_action('homepage', 'storefront_popular_products', 50); 
    remove_action('homepage', 'storefront_on_sale_products', 60); 
    remove_action('homepage', 'storefront_best_selling_products', 70); 
    add_action('homepage', 'storefront_best_selling_products', 10); 
    **<--- HERE I WANT TO ADD MY OWN PHP CODE (ADVANCED CUSTOM FIELD GALLERY FIELD)** 
    add_action('homepage', 'storefront_recent_products', 30); 
} 
add_action('init', 'storefront_child_reorder_homepage_contant'); 

あなたは私が欲しい見ることができるように: 1.ベストセラー商品2. ACFギャラリー 3.最近の製品最高の販売と最近の製品間のギャラリーを生成するために、私のカスタムコードを追加する方法

答えて

1

は、[OK]を私はそれを考え出した:

function storefront_child_add_custom_php() { 
    PHP CODE HERE 
} 

function storefront_child_reorder_homepage_contant() { 
    remove_action('homepage', 'storefront_homepage_content', 10); 
    remove_action('homepage', 'storefront_product_categories', 20); 
    remove_action('homepage', 'storefront_recent_products', 30); 
    remove_action('homepage', 'storefront_featured_products', 40); 
    remove_action('homepage', 'storefront_popular_products', 50); 
    remove_action('homepage', 'storefront_on_sale_products', 60); 
    remove_action('homepage', 'storefront_best_selling_products', 70); 
    add_action('homepage', 'storefront_best_selling_products', 10); 
    add_action('homepage', ' storefront_child_add_custom_php', 20); 
    add_action('homepage', 'storefront_recent_products', 30); 
} 
add_action('init', 'storefront_child_reorder_homepage_contant'); 
関連する問題