Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've included the code I'm working with below. I had some custom work done on a wordpress site of mine. This is a page that shows an list of the categories along with images and a short description. I'm not quite sure how to go about exclude a single category from showing up on this page.

This is a media site, so all of the categories correspond to productions. I'd like to create a blog, but am unable to until I can find a way to exclude the category from showing up on our production page. Any help would be appreciated, can typically work my way through WP, this one has me stumped at the moment.

<?php include( TEMPLATEPATH . '/admin/admin-init.php' ); ?>
    <div id="main">

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

        <div class="post" id="post-<?php the_ID(); ?>">
            <h2><?php the_title(); ?></h2>
            <div class="post-content">
                <?php the_content(); ?>
            </div>

    <?php endwhile; endif; ?>

            <div class="divider"></div>

            <div class="image-gallery categories-archive">  

                <?php

                $categories = get_categories('hide_empty=0');
                $imgs = get_option('ciii_image_names');
                $upl = wp_upload_dir();

                foreach ($categories as $c): ?>
                    <?php
                    $img = isset($imgs[$c->term_id]) ? $upl['baseurl'].'/category-images-ii/'.$imgs[$c->term_id]['original'] : $upl['baseurl'].'/dummy-285x175.png';
                    ?>

                    <div class="one_third">
                        <div class="post-img-medium">
                            <a href="<?php echo get_category_link($c->term_id) ?>" rel="bookmark" title="<?php echo $c->cat_name ?>"><img src="<?php echo $img ?>" width="285" /></a>
                        </div>
                        <h2 class="post-title"><a href="<?php echo get_category_link($c->term_id) ?>" rel="bookmark" title="<?php echo $c->cat_name ?>"><?php echo $c->cat_name ?></a></h2>
                        <p><?php echo $c->description ?></p>
                    </div>
                <?php endforeach; ?>
                <div class="clear"></div>

            </div>

        </div><!--post-->

    </div><!--main-->
share|improve this question
add comment

2 Answers

If everything else is doing what you want, change this line:

$categories = get_categories('hide_empty=0');

To this:

$categories = get_categories('hide_empty=0&exclude=10');

Swap '10' with the category number you want to exclude.

share|improve this answer
add comment

you can use this code...

<?php $categories = get_categories( $args ); ?> 

<?php $args = array(
    'type'                     => 'post',
    'orderby'                  => 'name',
    'order'                    => 'ASC',
    'hide_empty'               => 1,
    'exclude'                  => 'ID';
?> 

Thanks,

Nasir

share|improve this answer
    
it won't work. First: you call get_categories function before initialization of $args variable. Second: you have error in syntax of array declaration. And third: you use exclude argument incorrectly, there should be IDs of posts to exclude. –  Eugene Manuilov May 23 '12 at 7:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.