how can I get cat id in an array?
for example
cat id name
1 topcat1
2 ----sub1
3 -----sub2
4 topcat2
5 topcat3
6 ----sub31
I want get 1 4 5,what can I do?
could you help me?thanks!
how can I get cat id in an array?
for example
cat id name
1 topcat1
2 ----sub1
3 -----sub2
4 topcat2
5 topcat3
6 ----sub31
I want get 1 4 5,what can I do?
could you help me?thanks!
I'm not entirely sure I understand what you're asking. Are you saying you want an array with just the top categories? And are you asking for the MySQL query to obtain that?
Yes I want an array with just the top categories! Either mysql query or WP templates tag is OK!templates tag is preferred
I don't think it's possible with template tags (although I don't understand why not). I see no parameters that allow you to just pull top-level categories.
But the MySQL query would look something like:
SELECT cat_ID FROM wp_categories WHERE category_parent = 0
Note that in WP2.1 or greater, this will also retrieve categories for your blogrolls since they rolled that into the wp_categories table in Ella.
If you want to eliminate those, you would have to a bit more complicated query with joins to another table or two. Do you need that, too?
thank you It seems I should use mysql query,:)
This topic has been closed to new replies.