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(); ?>

    <?php endwhile; endif; ?>

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

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


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

                foreach ($categories as $c): ?>
                    $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>
                        <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>
                <?php endforeach; ?>
                <div class="clear"></div>




3 Answers 3


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.


Instead of $categories = get_categories('hide_empty=0'); you can use

$args = array("hide_empty" => true, "exclude" => 1); // replace 1 with your Category ID you want to exclude $categories = get_categories($args);


you can use this code...

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

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



  • 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. Commented May 23, 2012 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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