I have a need to export and display all category and subcategory names for a particular blog. The trick is to have them exported in a way that retains the category parent structure.
Has anyone had to do this by any chance and has a query handy?
I have a need to export and display all category and subcategory names for a particular blog. The trick is to have them exported in a way that retains the category parent structure.
Has anyone had to do this by any chance and has a query handy?
I've started with this...
SELECT sc.cat_name, wb.domain
FROM wp_sitecategories sc, wp_blogs wb
WHERE wb.domain = 'ablog.mydomain.net'
ORDER BY sc.cat_name
...but I'm not sure how to get them in the Category Parent structure that they are set to in the backend...
Have you looked at the WP and WPMU codex?
get_categories might be a good starting place and it gives you the advantage that if WP ever change the DB structures round categories your code wont break.
...duly noted, thanks Steve.