0

I want to display taxonomies instead of categories on the homepage of my blog. What can I do to achieve this?

1
  • 1
    If you want a good answer, you are going to have to explain yourself a little better. Where are the categories currently displayed? How are they displayed? What code are you using right now to display the categories?
    – Jared
    Jan 19, 2012 at 10:56

3 Answers 3

2

I think what you are looking for is this: http://codex.wordpress.org/Function_Reference/get_terms

Example of how to get all my_taxonomy terms and echo them in an unordered list.

 $terms = get_terms( "my_taxonomy" );
 $count = count( $terms );
 if ( $count > 0 ){
     echo "<ul>";
     foreach ( $terms as $term ) {
       echo "<li>$term->name</li>";
     }
     echo "</ul>";
 }
7
  • i dont want to display taxonomy in list format. i want to display in the form of post.
    – neha
    Jan 17, 2012 at 10:55
  • @neha Well, you can use the $terms variable for anything, I was just giving you an example of how to grab all of the terms from a custom taxonomy and do something with them. :) I don't know exactly what you are trying to do with the terms so that is as specific as anyone can get.
    – Jared
    Jan 17, 2012 at 11:35
  • i exactly want to display post by term of taxonomy instead of categories. will u guide me if u know the exact code .if u know then please tell me also in which exact file i replace your code.
    – neha
    Jan 18, 2012 at 5:49
  • @neha The problem is I don't know exactly what you are trying to do, so I wouldn't know where you need to put the code. I suggest if you don't know much about PHP and WordPress to not go about trying to code things yourself. If you insist on coding it yourself anyways without prior PHP knowledge, you are going to have to play around with the code I posted above until it works how you want it, as it is the function you are looking for.
    – Jared
    Jan 18, 2012 at 8:18
  • i know PHP and wordpress but problem is that i want the suitable code for my query.actually my boss doesnt want the taxonomy in list format . i used this code already thats y i want new code to fulfill boss requirement.
    – neha
    Jan 18, 2012 at 9:04
1

@neha In the code posted by Jared, please look at this line --> echo "<li>$term->name</li>

That's what made the output into a list.

For anyone to suggest the code, you should've mentioned how would you like to have it output?

Say, for a big title --> echo "<h1>$term->name</h1>
Or, into a blockquote --> echo "<blockquote>$term->name</blockquote> Or, as a regular paragraph --> echo "<p>$term->name</p>

How exactly would you like it to be displayed?

0

Try

wp_list_categories('taxonomy=operating_system'); 
1
  • what's this what do u want to say?? In which file i replace this code?? i want to display post in terms of taxonomy instead of categories.
    – neha
    Jan 18, 2012 at 5:50

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.