簡體   English   中英

WooCommerce單一產品簡碼

[英]WooCommerce single product shortcode

我通過WooCommerce出售一種產品,所以我沒有店鋪頁面。 現在,我已將產品信息添加到主菜單中,但是我想實際使用產品簡碼在普通頁面上顯示完整的單個產品[product_page_ID =“ 99”],以便可以輕松地向其中添加其他內容也可以,然后將此頁面添加到我的菜單中。 但是然后我仍然會得到內容基本相同的單個產品帖子(可在... / shop / product下訪問),如何避免這種情況?

創建一個新頁面,並在其中添加以下短代碼[product_page id="123"] (用有效的產品ID替換123),根據需要添加其他內容,然后將該頁面添加到菜單中。

但是然后我仍然會得到內容基本相同的單個產品帖子(可在... / shop / product下訪問),如何避免這種情況?

在另一個線程上,我為您提供了一些有關重定向商店的代碼,您需要對其進行修改以包括單個產品頁面,這是更新的版本:

add_action( 'template_redirect', 'redirect_shop' );

function redirect_Shop() {

    // added is_product() conditional to stop users from accessing the single product page
    if( is_shop() || is_product() ) {

        //replace the link below to point to your custom product page
        header('HTTP/1.1 301 Moved Permanently');
        header('location:http://www.example.com/page');
        exit;

    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM