Title: foreach loop excluding a catagory
Last modified: August 20, 2016

---

# foreach loop excluding a catagory

 *  [cat5](https://wordpress.org/support/users/cat5/)
 * (@cat5)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/foreach-loop-excluding-a-catagory/)
 * I am trying to exclude a filter from a post. The theme I am using has the following
   code
 *     ```
       // Get the filter > Category of item
       	$catz = wp_get_object_terms($post->ID,'filters');
       	foreach($catz as $cat) { 
   
       		$currcat = $cat->slug;
       		$catname = $cat->name;
       		break;
       	}
       ```
   
 * I have tried putting putting an if ($cat = -20); to exclude my filter id, but
   it didn’t work. Also I tried (‘exclude=20&title_li=’) after filters, but that
   didn’t work either. This is the custom query
 *     ```
       $args = array(
       	'post_type'			=> 'portfolio',
       	'posts_per_page'	=> $counter_folio,
       	'paged'				=> $paged,
       	'order'				=> 'DESC'
       );
       ```
   
 * _[Please post code & markup between backticks or use the code button. Your posted
   code may now have been permanently damaged by the forum’s parser.]_
 * I thought I should put the exclude in this section of the code but it didn’t 
   work either.
    This is a template-portfolio file. thank you for your help.

The topic ‘foreach loop excluding a catagory’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [cat5](https://wordpress.org/support/users/cat5/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/foreach-loop-excluding-a-catagory/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
