【问题标题】:Woocommerce Force category choice before creating new product?Woocommerce 在创建新产品之前强制类别选择?
【发布时间】:2017-02-11 13:55:11
【问题描述】:

在创建新产品时,如何强制用户先选择类别产品,然后再继续编辑器?

我找到了一个成功的解决方案,但它适用于帖子而不是产品。 https://wordpress.stackexchange.com/questions/14403/force-category-choice-before-creating-new-post

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    如果您更改以下代码,您推荐的代码似乎对您有用:

      $post_type = 'post';
        if ( isset( $_REQUEST['post_type'] ) ) {
            $post_type = $_REQUEST['post_type'];
        }
    
        // Only do this for posts
        if ( 'post' != $post_type ) {
            return;
        }
    

    $post_type = 'product';
    if ( isset( $_REQUEST['post_type'] ) ) {
        $post_type = $_REQUEST['post_type'];
    }
    
    // Only do this for posts
    if ( 'product' != $post_type ) {
        return;
    }
    

    希望这对你有用。

    【讨论】:

    • 我试过了,当我点击“添加产品”时,我得到页面强制我选择一个类别,但它列出了帖子类别而不是产品类别。
    猜你喜欢
    • 2021-01-17
    • 2014-09-13
    • 2021-06-02
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 2013-05-20
    • 1970-01-01
    • 2013-07-09
    相关资源
    最近更新 更多