Adding categories to all blogs at once

I am using WordPress mu 2.9.2 and have the same category structure on all my blogs. How do I add categories to all my blogs simultaneously? Is there a plugin that does this effectively?

Related posts

Leave a Reply

1 comment

  1. You could write a script for that, here is something I wrote in Perl lately:

    1. first the sql statements to check if the term already exist and if not insert it:

    the prepared statements:

    my $wts    = $dbh->prepare(
    "SELECT term_id FROM $tb_wp_terms WHERE name = ?")
    or die "Couldn't prepare statement: " . dbh->errstr;
    
    my $wti    = $dbh->prepare(
    "INSERT INTO $tb_wp_terms
    (name, slug) VALUES (?,?)")
    or die "Couldn't prepare statement: " . dbh->errstr;
    
    1. then make the term taxonomy entry:

    the prepared statements:

    my $wtts    = $dbh->prepare(
    "SELECT term_taxonomy_id FROM $tb_wp_term_taxonomy WHERE term_id = ? 
     AND taxonomy = '".$config{'wordpress.taxonomy_type'}."'")
     or die "Couldn't prepare statement: " . dbh->errstr;
    
    my $wtti    = $dbh->prepare(
    "INSERT INTO $tb_wp_term_taxonomy
    (term_id, taxonomy, count) VALUES (?,?,1)")
    or die "Couldn't prepare statement: " . dbh->errstr;
    
    my $wtts_count    = $dbh->prepare(
    "SELECT count FROM $tb_wp_term_taxonomy WHERE term_taxonomy_id = ? AND taxonomy =
       '".$config{'wordpress.taxonomy_type'}."'")
    or die "Couldn't prepare statement: " . dbh->errstr;
    
    my $wtti_count    = $dbh->prepare(
    "UPDATE $tb_wp_term_taxonomy
     SET count = ?
     WHERE term_taxonomy_id = ?
     ")
    or die "Couldn't prepare statement: " . dbh->errstr;
    

    And use the queries above with some code around it (you need to check for blogs that already have some of the categories).

    For MU only the blogs > 1 get a blog id in their table name:

    my $tb_blogid = "";
    if ( $config{'wordpress.wp_mu_blog_id'} > 1 )
    {
    $tb_blogid = "_" . $config{'wordpress.wp_mu_blog_id'};
    }
    my $tb_posts                    = $config{'wordpress.prefix'} . $tb_blogid . "_posts";
    my $tb_wp_terms                 = $config{'wordpress.prefix'} . $tb_blogid . "_terms";
    my $tb_wp_term_taxonomy         = $config{'wordpress.prefix'} . $tb_blogid .     
    "_term_taxonomy";
    my $tb_wp_terms_relationships   = $config{'wordpress.prefix'} . $tb_blogid . 
    "_term_relationships";
    

    So just loop through them.