1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Easiest way to mass-edit all posts?

Discussion in 'Blogging' started by Dodge, Aug 9, 2011.

  1. Dodge

    Dodge Regular Member

    Joined:
    Jul 29, 2009
    Messages:
    389
    Likes Received:
    53
    Hi there,

    I have a couple of TV series sites using WP, but want to add in some kind of feature where users can report any problems with the video, which would then be emailed to me...

    Does any one have any idea how I could do this, and then easily add it to all my posts (there are too many to do manually), or if there is a plug in that would do this?

    Thank you!
     
  2. devoted

    devoted Registered Member

    Joined:
    Aug 31, 2010
    Messages:
    57
    Likes Received:
    7
    no need to edit all posts, but you will have to add some php code in ur template (single post).. just an idea sir g
     
  3. CyberSEO

    CyberSEO Senior Member

    Joined:
    Jul 14, 2011
    Messages:
    939
    Likes Received:
    256
    Occupation:
    programmer
    Home Page:
    That's very easy. Here is the script:

    Code:
    <?php
    // AddMe.php - the simple script that adds some given html code to every published post in the WP database
    // Put in into your WP root folder and simple run it once. e.g.: http://www.yourblog.com/addme.php
    // Don't forget to delete addme.php from your server when done! And do not run it twice!
    // Written by http://www.CyberSEO.net
    define ( 'TO_ADD', '<p>PUT HERE SOMETHING YOU WANT TO ADD</p>' );
    include ("wp-config.php");
    $wp_upload_dir = wp_upload_dir ();
    $query = "SELECT ID, post_content, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post'";
    $posts = $wpdb->get_results ( $query );
    echo 'Addding. Please wait...<br />';
    foreach ( $posts as $post ) {
        $post->post_content .= TO_ADD;
        $post->post_excerpt .= TO_ADD;
        wp_update_post ( $post );
    }
    echo 'Done!<br />';
    echo 'Don\'t forget to delete addme.php from your server!';
    ?>
     
    • Thanks Thanks x 1
    Last edited: Aug 9, 2011
  4. Dodge

    Dodge Regular Member

    Joined:
    Jul 29, 2009
    Messages:
    389
    Likes Received:
    53
    Perfect, thank you! So then I'd just need to enter some HTML code that will allow the email submit?
     
  5. mickeylove

    mickeylove Registered Member

    Joined:
    Jul 26, 2011
    Messages:
    55
    Likes Received:
    2
    Not sure if this helps, but I did something similar last night, with help in this thread

    /blogging/339548-adding-affiliate-ads-wordpress-site.html
     
  6. CyberSEO

    CyberSEO Senior Member

    Joined:
    Jul 14, 2011
    Messages:
    939
    Likes Received:
    256
    Occupation:
    programmer
    Home Page:
    Yes, you have to put it here:

    define ( 'TO_ADD', '<p>PUT HERE SOMETHING YOU WANT TO ADD</p>' );

    Then simple save the script as addme.php, upload it to your WP root folder and run it once, e.g.: http://www.yourblog.com/addme.php

    Remove the script from server when done!
     
  7. Dodge

    Dodge Regular Member

    Joined:
    Jul 29, 2009
    Messages:
    389
    Likes Received:
    53
    Thanks, really appreciate that! I don't know HTML but I think there are plenty of sites that can give me the code for this email submit thing anyway!
     
  8. VIC SEO

    VIC SEO Elite Member

    Joined:
    Feb 19, 2010
    Messages:
    2,156
    Likes Received:
    363
    Gender:
    Male
    Occupation:
    SEO Specialist
    Location:
    iSynergyMedia
    Home Page:
    I don't think you can mass edit all posts, you have to do that manually. But you can mass perform a single action on all of them.
     
  9. digibing

    digibing Junior Member

    Joined:
    Mar 18, 2010
    Messages:
    150
    Likes Received:
    28
    As the previous guy said, just edit the template.

    But if you want to add something to all posts, try exporting the database in phpmyadmin as a text file. Use a good file editor to add your desired code at whatever marker signifies the beginning, or end, of a post. Then import the text file into the database again. Remember to backup before you attempt this though.