Traffic is all about SEO Optimizing and Rankings. This post includes the most powerful wordpress hacks which will help you gaining top positions in Search Engines and Improve SEO Rankings. WordPress is already 60% SEO optimized CMS but when it comes to rankings, then you need to do external mindsets for ranking on the top in the Search Engines.
These WordPress Snippets, Tricks are must for every WordPress user, if you want to rank better. These snippets helps Search Engine bots, like Google bots to identify your content well and crawl the pages faster with effectiveness. What we will be doing to improve SEO is just editing some files, mainly the most powerful file .htaccess
to get the most out of your blog. So, lets get started.
Contents
WordPress Hacks to Improve SEO
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 those Pages which are generated when there is no content on the page you have specified. The bad part of 404 pages is that, 404 Pages decreases the Pagerank of your blog making your site rankings ineffective. So, what we will be doing to Improve SEO is utilizing the WordPress Hack to redirect the 404 Error Pages to the Blog’s Homepage.
Automatically Remove Stop Words from 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 your blog post in WordPress, the permalink adjusts according to the title you wrote. It is considered that we should not use Stop Words like, for, the,is etc in the permalinks of blog posts. It improves SEO and also helps to expect the content from the URL only. So, to make the job automatically done, use the snippet to automatically remove stop words from permalink to Improve 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 to highlight the Searched Words in the_excerpt and the_title of the searched results on your blog.
Rewrite Search Result Permalinks
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 snippet helps you to rewrite the Search Results Permalink like “yourblog.com/search/searched-keyword“, ultimately its better than the default search permalinks, hence improves SEO.
Disallow Directories for Google Bots
User-agent: Googlebot
Allow: /?display=wide
Disallow: /wp-content/
Disallow: /trackback/
Disallow: /wp-admin/
Disallow: /feed/
Disallow: /index.php
Disallow: /*?
Disallow: /*.js$
Disallow: /*.inc$
Disallow: /*.css$
Disallow: */feed/
Disallow: */trackback/
Disallow: /link.php
Disallow: /gallery2
Disallow: /gallery2/
Disallow: /refer/
User-agent: Googlebot-Image
Disallow: /wp-includes/
User-agent: Mediapartners-Google*
Disallow:
Use this piece of snippet in your robots,txt file to prevent Gogole Bots to index undesired directories like wp-content, wp-includes etc.
To be honestly I haven’t optimized my blog for 404 pages error.Now I’m going to optimize 404 error pages in my blog 🙂 Thanks for this technique.
Yup, you should. Its most important to hide the 404 pages from Google.
Another trick …Make quality articles for readers not for Search Engines
Its obvious, if you want to rank on the first page.
Hi DesignSkew.com,
Thank you for this very useful information, and for share it!
I have a very basic question as well. Where exactly do i have to put the snippets? You say in htaccess file and rest to be in functions.php, but “where exactly”, after what?
Sorry for my low level, and thank you again for this wonderful article. 😉
Its fine, I feel good to help newbies, exactly I can’t tell because it is different for different theme. But in most condition, you can try adding the snippets in the bottom of the functions.php file, and same for htaccess, in the bottom of the file.
Also, don’t forget not to leave any blank line in the end of functions.php file.
Thank you very very very much! 😉
Thanks for these hacks! I’m gonna use the Search Results hacks on my sites 🙂
thanks for your bunderful artical and unique contents these are very usefull
Nice coding *hacks* Thanks for the update! 🙂
Keep up the good work Buddy!
Great tips here. This is exactly bloggers like me should learn how to code – it puts them in a position where they can optimize not only on-page, but also site elements and functions for better user experience. Oh, the envy!
Well,
Hacking is not a easy task so I appreciate the work you describe in this post.
Great idea but confusion because hacking is not a simple task and I would like to give it a try if you help me for one of my website. Will I send my website access to you??
Hi!
Your website is way too good. I enjoy the valuable data you deliver to your posts. I will save your blog page and look all over again in this article routinely.
Also i hope your post will help me improve my website.
Hey Mani,
Modifying robots.txt file and disallowing affiliate links as well as directory would help us to get quick ranking.Premalink is also important, however during recent Google algorithm updates, I am using harsh agrawal’s tips of removing dates from blogpost will also be helpful for SEO.
I have personally experienced it and removed dates from one of my blog to test the results. It helped me to recover 20% of my lost traffic and still I am trying new stuffs to recover my lost traffic on my blog.
Thanks for the great article.
Hi Mani,
Custom 404 page is a must for every blog, having a custom 404 pages reduced your bounce rate, improve your SEO.
I’m sure it’s going to be very helpful.
Thanks for sharing
Keep up the good work and I hope you keep bringing articles such as this
Memorial Day 2015
Hi Mani,
Thanks for these hacks! I’m gonna use the Search Results hacks on my sites
Best Online Tools To Know Everything About Website
Thank you for this very useful information and for share it!
I have a very basic question as well. Where exactly do I have to put the snippets? You say in htaccess file and rest to be in functions.php, but “where exactly”, after what?
Sorry for my low level, and thank you again for this wonderful article.