Easiest way to mass-edit all posts?

Dodge

Regular Member
Joined
Jul 29, 2009
Messages
389
Reaction score
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!
 
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
 
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!';
?>
 
Last edited:
That's very easy. Here is the script:

Code:
<?php
// AddMe.php - simple script that adds a 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!';
?>
Perfect, thank you! So then I'd just need to enter some HTML code that will allow the email submit?
 
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
 
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!
 
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!
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!
 
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.
 
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.
 
Back
Top