X

5 WordPress Tricks to Improve SEO of Your Blog

This post includes a few important tricks for wordpress that will help you earn positions in search engines and also can be used to improve SEO of your blog will help you out. These tips will help the search engine bots, to better identify the content of your blog and perform a scan of your pages faster and more effective.

Redirect 404 pages

< IfModule mod_alias.c >
 RedirectMatch 301 ^/search/$ http://your-site.com/
 RedirectMatch 301 ^/tag/$ http://your-site.com/
 RedirectMatch 301 ^/category/$ http://your-site.com/
< /IfModule >

404 error pages are pages that are raised when the content is not found on the page that you specified. The negative about point 404 pages is that they decrease the Pagerank of your blog by demoting the positioning of the site. So to improve SEO, we will put these provisions in the .htaccess file of our blog that will redirect 404 error pages to the home page of the blog.

Automatically remove stop words from the URL

add_filter(‘sanitize_title’, ‘remove_short_words’);
 function remove_short_words($slug) {
 if (!is_admin()) return $slug;
 $slug = explode(‘-‘, $slug);
 foreach ($slug as $k => $word) {
 if (strlen($word) < 3) {
 unset($slug[$k]);
 }
 }
 return implode(‘-‘, $slug);
 }

When you write a title for the post in WordPress, the permalink is generated from the title you specified (if you haven’t customized its structure). As a general rule we should not break the words such as articles, prepositions, conjunctions, punctuation etc in the permalink of the post. The above code (to be inserted in the file function.php) serves precisely to remove stop words automatically by a tangible improvement permalink for SEO.

Highlight keywords in search results

function wps_highlight_results($text){
 if(is_search()){
 $sr = get_query_var(‘s’);
 $keys = explode(" ",$sr);
 $text = preg_replace(‘/(‘.implode(‘|’, $keys) .’)/iu’, ‘<strong>’.$sr.'</strong>’, $text);
 }
 return $text;
 }
 add_filter(‘the_excerpt’, ‘wps_highlight_results’);
 add_filter(‘the_title’, ‘wps_highlight_results’);

Use this snippet of code (to be inserted in the file function.php) to highlight the search words in the summary of the post (the_excerpt) and titles (the_title) that appear in the search results of your blog.

Rewrite permalinks of search results

function search_url_rewrite_rule() {
 if ( is_search() && !empty($_GET[‘s’])) {
 wp_redirect(home_url("/search/") . urlencode(get_query_var(‘s’)));
 exit();
 }
 }
 add_action(‘template_redirect’, ‘search_url_rewrite_rule’);

This code snippet allows you to rewrite permalinks of search results in the format “yourblog.com/search/keyword-searches”, which improves SEO.

The “Disallow” greeting cards for Google Bots

User-agent: Googlebot
 Allow: /?display=wide
 Disallow: /wp-content/
 Disallow: /trackback/
 Disallow: /wp-admin/
 Disallow: /feed/
 Disallow: /index.php
 Disallow: /*?
 Disallow: /*.inc$
 Disallow: */feed/
 Disallow: */trackback/
 Disallow: /link.php
 Disallow: /refer/
 User-agent: Googlebot-Image
 Disallow: /wp-includes/
 User-agent: Mediapartners-Google*
 Disallow:

It is possible to insert this text list (possibly to change according to their own needs) in your robots.txt file to prevent the Google Bot indexing unwanted directories like wp-admin, wp-includes etc.

 

shyambhardwaj:
Related Post