Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Actually before doing that, all you may need to do is customize the sidebar widget. You can do that in your WordPress Dashboard by:

    • Going to “Appearance” > “Widgets”
    • Selecting the sidebar of the page you want to modify
    • And finally adding in the widgets you want in it

    That should clear out the default widgets (like the search, too) from the sidebar.

    Hi, JodieRD.

    If you’re comfortable with copying and tweaking PHP, try using this snippet I found at WPExplorer.com into your theme’s functions.php file:

    add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
    2
    
    3
    function custom_pre_get_posts_query( $q ) {
    4
    
    5
        if ( ! $q->is_main_query() ) return;
    6
        if ( ! $q->is_post_type_archive() ) return;
    7
    
    8
        if ( ! is_admin() && is_shop() && ! is_user_logged_in() ) {
    9
    
    10
            $q->set( 'tax_query', array(array(
    11
                'taxonomy' => 'product_cat',
    12
                'field' => 'slug',
    13
                'terms' => array( 'color', 'flavor', 'spices', 'vanilla' ), // Don't display products in these categories on the shop page
    14
                'operator' => 'NOT IN'
    15
            )));
    16
    
    17
        }
    18
    
    19
        remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
    20
    
    21
    }

    Caveat: I haven’t tried this out myself; and it may just remove specific product categories.

    Hi, grim_reaper.
    Mind sharing what the fix was? Just curious.

Viewing 3 replies - 1 through 3 (of 3 total)