How to Exclude Category from foreach loop
-
Hi,
I’ve been looking around Google and experimenting myself for hours but I can’t figure it out.
Please can someone show me how to exclude a category from this exact loop:
<?php $i = 1; ?> <?php foreach ( $categories as $category ) : ?> <input type="radio" name="category" value="<?php echo $category->term_id; ?>" id="<?php echo $category->slug; ?>"<?php echo ( ! isset( $_POST['category'] ) && 1 == $i ? ' checked' : '' ); echo ( isset( $_POST['category'] ) && $_POST['category'] == $category->term_id ? ' checked' : '' ); ?> /><label for="<?php echo $category->slug; ?>"><?php echo $category->name; ?></label> <?php $i++; ?> <?php endforeach; ?>
What it’s doing is creating a check box and label from all my categories but I want to exclude one.
Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to Exclude Category from foreach loop’ is closed to new replies.