0

我们现在有一种产品。我希望我们的产品成为商店页面。你知道我如何制作我创建的产品到购物页面吗?如果用户点击商店,它应该只显示我的单个产品。不是产品列表,因为我们只有一种产品。产品意味着它在该页面中有添加到购物车按钮。所以商店页面应该显示带有添加到购物车按钮、产品信息、价格等所有内容的产品页面。

例如,我希望用户单击商店页面,它应该像这样链接到我的单个页面。 http://www.garageclothing.com/us/hooded-flannel-plaid-shirt/p/100009673

4

1 回答 1

2

我认为您应该能够过滤template_redirect.

function so_template_redirect(){
    if( function_exists( 'is_shop' ) && is_shop() ){
        $product_id = 999; // change to the ID of your 1 product
        $permalink = get_permalink( $product_id );
        wp_redirect( $permalink );
        exit();
    }
}
add_action( 'template_redirect', 'so_template_redirect' );
于 2015-11-20T18:37:58.303 回答