in

How to Prevent Duplicate Post Titles in WordPress?

How to Prevent Duplicate Post Titles in WordPress?

Correct search engine optimization is necessary for a website to rank higher. Though different factors directly affect the raking of a website. Some might help your site in increasing the ranking, while others could bring it down to the bottom and one of those factors is the title of the post. A useful title with the necessary keywords and the length will help you in getting a better ranking. However, putting the same title on two different blogs will not act the same way.

The primary reason for not using duplicate title is that it might leave your users confused. The best you can do is to make minor changes in the title like adding numbers or the year of posting that will help your readers in differentiating with the content.

The problem of duplicate posts mainly occurs in the multi-author sites. By looking at the title, the author will get the idea of whether they have posted such blog or not. In a multi-author site, there is very less chance that one author will know about the blogs posted by other offers which increases the chances of duplicate posting which can degrade the rankings of the site. Here we present you with the complete method of avoiding duplicate titles in WordPress.

Method 1 – The Manual Method

Step 1

This process requires you to add specific codes in the WordPress core files, so you need to be aware of the WordPress coding. In this process, the first thing you need to do is log in to your FTP client and open the WordPress root directory. Here you need to open the wp-content folder where you can find all the contents of your site.

Step 2

Now head over to the Themes> Your Current Theme folder, and download the functions.php file to your local system. Open that file using any of the text editors and paste the following code into the file.

function disallow_posts_with_same_title($messages) {

global $post;

global $wpdb ;

$title = $post->post_title;

$post_id = $post->ID ;

$wtitlequery = “SELECT post_title FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_type = ‘post’ AND post_title = ‘{$title}’ AND ID != {$post_id} ” ;

$wresults = $wpdb->get_results( $wtitlequery) ;

if ( $wresults ) {

$error_message = ‘This title is already used. Please choose another’;

add_settings_error(‘post_has_links’, ”, $error_message, ‘error’);

settings_errors( ‘post_has_links’ );

$post->post_status = ‘draft’;

wp_update_post($post);

return;

}

return $messages;

}

add_action(‘post_updated_messages’, ‘disallow_posts_with_same_title’);

Step 3

Upon pasting the code, you need to save the file and upload it back to your server. Now you need to Save a post with a duplicate title. After saving the post, the code runs a query that checks your complete WordPress database for any other post with the same title and displays a warning that this title has been already used in other posts.

If you are not comfortable with the website coding, then there is another method that you can use for the same task where you need to install a plugin.

Method 2 – The Plugin Method

Step 1

In the first step, you need to install and activate a plugin called as the Unique Title Checker. To install this plugin, the first thing you need to do is log in to your WordPress admin dashboard and navigate to the Plugins> Add New page. Find the plugin in the WordPress store and hit the Install Now button. Once the installation completes, you need to click on the Activate Plugin link to start using it.

Step 2

There are no such configurations that you need to make in this plugin. To check whether the plugin is working correctly or not, you need to open the Posts> Add New posts from the WordPress admin panel. Now in the title field, you need to enter a title which you have already used in any other post. After entering the duplicate title, you will notice an error on top of the post editor screen stating that the title has been already used in the different post. This error will let you and your other authors know about any other post using the same method.

Unique Title Checker

There is another plugin which can help you in the same process, and that is Similar Post-Title Checker. Similar to the Unique Title Checker, this plugin also works out of the box. One of the best things about this plugin is that it not only identifies duplicate titles but also provides you with similar post titles as well. This feature allows you to avoid utterly similar titles and helps you create genuine ones.

Similar Post-Title Checker

Endnote

These were some of the best methods to prevent duplicate post titles. It all depends on you that which method you want to do with. However, the easiest way is the plugin method as there are no such configurations and complications included.

Leave a Reply

Your email address will not be published. Required fields are marked *

How to View and Control WordPress Cron Jobs?

How to View and Control WordPress Cron Jobs?

How to Disable Unwanted Widgets in WordPress?

Disable Unwanted Widgets in WordPress