Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: woocommerce admin panel add new product page manipulate product...

Discussion in 'Misc WordPress Requests' started by Peter Hardy-vanDoorn, Jan 26, 2018.

  1. Peter Hardy-vanDoorn

    Guest

    Reply To: woocommerce admin panel add new product page manipulate product categories, by Peter Hardy-vanDoorn

    You can alter the WordPress queries before the query is run using the pre_get_posts() action.

    For example, here’s how I exclude 2 categories from search results on one of my sites:

    function ma_exclude_wlb_search( $query ) {
    if ( !is_admin() && $query->is_main_query() && $query->is_search() ) :
    $tax_query = array( 'post_type' => 'product',
    'tax_query' => array( array(
    'taxonomy' => 'product_cat',
    'field' => 'ID',
    'terms' => array ( 23, 74 ),
    'operator' => 'NOT IN' ),
    ),
    );
    $query->set( 'tax_query', $tax_query );
    endif;
    }
    add_action( 'pre_get_posts', 'ma_exclude_wlb_search' );


    Hopefully that will give you enough of a pointer to work out how to exclude the categories from editing products.

    Reply To: woocommerce admin panel add new product page manipulate product categories
     
    #1

Share This Page

Monarch Social Sharing Plugin