It is very interesting to maintain a WordPress blog. You have to perform a number of tasks such as getting the website designed, choosing a relevant theme and writing unique and appropriate posts to attract more traffic. But with time you realize that visitor flow to your blog is less and your web host has less bandwidth.
It takes a lot of time and effort to enhance the presence of your blog. Sometimes, there are certain major changes that need to be done.

Modifying Posts With One SQL Command
There are thousands of posts in your blog in which Google adverts are inserted manually. If you want a minor editing, you have to make changes in all these posts. This is a tedious task.
However, certain tools are available which can make this process simpler. Here we discuss how you can edit a large number of posts with a SQL command. You need a phpMyAdmin to start this process. Go to the menu on the left. Select your blog’s database.

There is a code in SQL tag. This code will be used to remove various sections of the content. It will delete the content you have selected on any number of blog posts. But the condition is that the start text and end text should be common in all the content. For example, there is a common start and end tag in Google advert.

The screenshot below displays the blog entries in which the ad is manually inserted on each page after ‘more’ tag.

The code will make your page appear like the following screenshot.

There is a ‘script type’ start tag which can be used before every advert. The end of the advert has a‘script src’ tag.
If you want to remove an entire block of a page, you have to use the ‘update’ command of SQL. You must understand three functions of MySQL: locate, replace and substr.
LOCATE is used to inform the SQL command about the start & end points location. Here, strings are used before and after the section. Following is the command for the location of the start point on a page:
LOCATE (‘<script type=”text/javascript”>’, post_content)
The end point location is little complicated. You get a start for a string. In order to get the end point location, the total characters have to be added. Check out the following command.
LOCATE(‘<script src=’http://pagead2.googlesyndication.com/pagead/show_ads.js” type=”text/javascript”>’, post_content) + 93
Use REPLACE to remove the text you do not require. You need to tell the function which text is no longer required. Use SUBSTR to take out the string from your post content. You need to give details of your starting location and length.
When the code is inserted to SUBSTR function, it looks like the following:
substr(post_content, locate(‘<script type=”text/javascript”>’, post_content), ((locate(‘<script src=”http://pagead2.googlesyndication.com/pagead/show_ads.js” type=”text/javascript”>’, post_content) + 93) – (locate(‘<script type=”text/javascript”>’, post_content))))
It includes three sections: post content, length and start location.
This defines the text you wish to wipe from the posts. Now simply use REPLACE to remove it. Add the code in the command below:
UPDATE wp_posts SET post_content = replace(post_content, string_to_replace, replacement_string);
It will appear like the following:
UPDATE wp_posts SET post_content = REPLACE(post_content, substr(post_content, locate(‘<script type=”text/javascript”>’, post_content), ((locate(‘<script src=”http://pagead2.googlesyndication.com/pagead/show_ads.js” type=”text/javascript”>’, post_content) + 93) – (locate(‘<script type=”text/javascript”>’, post_content)))), ‘ ‘);
If there is proper alignment of the syntax, your phpAdmin will show successful results as shown in the screenshot below.

When the posts are reloaded in the browser, the ad will not be displayed.

However, there are certain ads that have different formatting like the page below.

In such a case, change precise tags at the start and end. Use the SQL command again and remove the tags.

You can delete any content in the WordPress post by using this technique. You can easily use the SQL commands for editing a large number of posts. This saves you from working manually. You must remember that a proper backup of your database has to be maintained before you begin with the process.
0 comments:
Post a Comment