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

On my main page I have a few post from two categories, but I only want it to display only one

Here is my code

/* translators: used between list items, there is a space after the comma */
    $categories_list = get_the_category_list( __( ', ', 'themename' ) );
        if ( $categories_list && themename_categorized_blog() ) :
<?php printf( __( '%1$s', 'themename' ), $categories_list ); ?> 

Is it possible to do it by adding this [0] in the code somewhere, if so, where?

share|improve this question
Could you explain what it is you're trying to do exactly? – Howdy_McGee Jun 5 '14 at 13:39
Yes on my main page i have a few post that show two category(s) but i only want it to show one only – H3r0k0 Jun 5 '14 at 13:59
I have updated your question from your comment, but still it don't make much sense. Check my answer, if it is not what you want, please be more clearer so that I can adjust my answer accordingly – Pieter Goosen Jun 5 '14 at 14:05
@PieterGoosen Check out the earlier question H3r0k0 asked. – ialocin Jun 5 '14 at 14:08
Thanks PieterGoosen should of linked my other question. – H3r0k0 Jun 5 '14 at 14:10

There are better suited functions to do what you want available.

In reference to your other, similar question, use get_the_category() like you did there. Or you can use get_categories() or wp_list_categories(). What to chose depends on your needs, for example in regards to formatting.

Btw, the question, what the main category is isn't as easy answerable, if we're talking about categories on the same level.

share|improve this answer

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.