All posts by dz42

Move WordPress to a New Domain Without Losing SEO

The process of switching to a new domain will temporarily affect your search engine rankings as Google and other search engines adjusts to the changes. This will also temporarily affect your search traffic as well. Please keep in mind that this is normal, and it happens to all sites that switch to a new domain.

Setting up Permanent 301 Redirects

Setting up a permanent 301 redirect is very important for both SEO and user experience. This allows you to redirect users and search engines to your new site. In other words, whenever someone lands on one of your old posts or pages, then they will be automatically redirected to your new site.

To setup a permanent 301 redirect, you need to connect to your old site using FTP and edit the .htaccess file. This will be located in the same directory as your wp-includes or wp-admin folder. Open the .htaccess file and paste the following code at the very top:

#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.newsite.COM/$1 [R=301,L]

Note: Replace newsite.com with your domain in the above code.
Once you have applied these changes, then visit your old site. It should automatically redirect you to the new site. If it doesn’t, then it means the redirection is not setup properly.

Notifying Google About the Change

Login to your Google Webmaster Tools account to submit a change of address. Basically click on your site and look at the configuration menu -> Change od Address. This allows you to notify Google about your new site and the transfer. Yes, you have to verify your new site, so go ahead and do it.

Show Different Number Of Posts Per Category In WordPress

Assume that we want to show 5 posts per page for category “WordPress” and 10 posts per page for category “News”, just open the functions.php file in your theme folder and insert these line into it:

add_action('pre_get_posts', 'diff_post_count_per_cat');
 
function diff_post_count_per_cat() {
    if (is_admin()) return;
 
    $cat = get_query_var('category_name');
    switch ($cat) {
        case 'wordpress':
            set_query_var('posts_per_page', 5);
            break;
        case 'wordpress/news':
            set_query_var('posts_per_page', 2);
            break;   
    }
}

Change “wordpress” and “news” into real category names of your blog. Note that in the code above, we use category slug, not original name. If the category is a child category, don’t forget to insert full path (i.e. “wordpress/news” in the example below).