Excluding a category from the Products Page

Excluding a category from the Products Page

To exclude products that belong to a particular category from the products page (Default,list or Grid). One solution is to put this code in your selected products page template just after the loop begins. eg. If you are using Grid View, place it here.

Where the ‘term id’ is the id of the catergory. You can find what that number is by looking at the URL after Selecting a category in Products ยป Categories.

in this example the Category ID is 3.

Also note that you need to close that else statement just before the ‘endwhile’ line. On the Grid view it should be around line 155

// add end to else




If you’re on a single product page, use this code to get an array of the current categories associated with the product from the loop. I hope it sets you in the right direction.

global $post;

$categories = get_the_terms( $post->ID, 'wpsc_product_category' );

foreach($categories as $cat){

$cname[] = $cat->name;

$catID = (int) $cat->term_taxonomy_id;

$clin[] = get_term_link( $catID, 'wpsc_product_category');


//name and links will be in those arrays, so first name is $cname[0] and first link is $clink[0]