WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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'm trying to get the code below to look up the status name, i.e. new, open, pending or resolved with the word ticket together to find pages called new tickets, open tickets etc.

$ticket_status = get_terms('ticket_status', 'orderby=description&hide_empty=0');
echo '<ul class="numberlist">';
if ($ticket_status) : foreach($ticket_status as $status) :

    if (!isset($counts[$status->slug])) :
        $counts[$status->slug] = '0';
    echo '<li><a href="'.
        add_query_arg($status->name, 'tickets').
share|improve this question
What is in your $status variable? have you tried to var_dump($status); it? – dalbaeb Apr 28 '13 at 21:38
Also, you'd probably want to switch the two, so that 'tickets' is the first parameter. – dalbaeb Apr 28 '13 at 21:40
Swapping gives me http://localhost/?page_id=38&tickets=pending – user31891 Apr 28 '13 at 21:48
I would like to find a page called pending tickets – user31891 Apr 28 '13 at 21:50
this takes me to a loop search for tickets meeting the status <a href="'.add_query_arg('assigned_to', get_current_user_id(), get_term_link($status->slug, 'ticket_status')).'"> I still want to look for page – user31891 Apr 28 '13 at 22:14

It depends a bit on what are your exact status slug and title and page title are, but something like this should work, if I understand you correctly:

$page = get_page_by_title($status->name." tickets");
echo '<li><a href="'.get_permalink($page->ID).'">'
      .$status->name.' (<span>'.$counts[$status->slug].'</span>)</a></li>';
share|improve this answer
Great that works a treat only grip is the links look like this new() open() pending() resolved() if (!isset($counts[$status->slug])) : $counts[$status->slug] = '0'; endif; $page = get_page_by_title($status->name." tickets"); echo '<li><a href="'.get_permalink($page->ID).'">' .$status->name.' (<span>'.$counts[$status->slug].'</span>)</a></li>'; endforeach; endif; echo '</ul>'; – user31891 Apr 28 '13 at 22:53
but removing the brackets around the span fixes that! Thanks alvaro.d – user31891 Apr 28 '13 at 22:55
Hmm, it should show (0) or (n) for $counts[$status_slug] = n. Can you please mark the question as asnwered then? – adelval Apr 29 '13 at 15:46

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.