WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've put some thought into this but Can't really figure out what direction I take in getting rid of certain terms in my testimonial_category called 'home', 'homeone', hometwo. I only want to stop these displaying in a link format on the relevant page.

Here is the code the process's all the terms within testimonial_category, I was thinking I need to somehow add a filter that stops these 3 named terms appearing as links but could really do with some advice on how to do this.

<div id="main" class="floatleft">

    <div class="case-study"> 
        <h1 class="p-title">Testimonials</h1>
        <div class="breadcrumb"> 
            <ul class="filter group">
                <li class="all current"><a href="#">All<span></span></a></li>
                $terms = get_terms("testimonial_category");
                $count = count($terms);
                if ($count > 0) {
                    foreach ($terms as $term) {
                        ?><li class="<?php echo $term->slug; ?>"><a href="#"><?php echo $term->name; ?><span></span></a></li><?php
        <div class="clear"></div>

Many thanks for any help.

share|improve this question
up vote 2 down vote accepted

The function get_terms has a convenient $args parameter which allows you to customize your query to meet your needs; in your case, it would be something as simple as:

$args = array(
    'exclude'       => array(1,2,3)

$terms = get_terms("testimonial_category", $args);

The array to exclude must contain the category ids of the categories you wish to leave out.

share|improve this answer
I'll try this solution, didn't even know you could exclude array id's like that. – dannyw24 Jul 8 '13 at 15:39
You can check the link provided to see all the available options. – Sunyatasattva Jul 8 '13 at 15:40
Thanks, I've learn't that now seems a very easy solution – dannyw24 Jul 8 '13 at 15:45

This is a bit of a hack... (hardcoding variables like this isn't best practice, IMO) but it's good example to get your wheels turning...

foreach ($terms as $term):?>

    <?php /*If the term name is anything but not 'home' or 'homeone' then echo the list item */ ?>
    <?php if($term->name != 'home' || $term->name != 'homeone' ):?>

        <li class="<?php echo $term->slug; ?>">
            <a href="#"><?php echo $term->name; ?><span></span></a>

    <?php endif; ?>
<?php endforeach; ?>
share|improve this answer
Although I could see this working, I think the other solution is neater. – dannyw24 Jul 8 '13 at 15:44

Your Answer


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.