The MU forums have moved to WordPress.org

Does anyone here have a handy SQL query that will help? (4 posts)

  1. awarner20
    Member
    Posted 14 years ago #

    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?

  2. awarner20
    Member
    Posted 14 years ago #

    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...

  3. SteveAtty
    Member
    Posted 14 years ago #

    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.

  4. awarner20
    Member
    Posted 14 years ago #

    ...duly noted, thanks Steve.

About this Topic

  • Started 14 years ago by awarner20
  • Latest reply from awarner20