Disable “Install the WooThemes updater plugin to get updates”

Here’s a single line code which allows you to get rid of annoying WooCommerce admin notices i.e “Install the WooThemes updater plugin to get updates for your WooThemes plugins”.

All you need to do is copy the following code snippet and paste it inside your functions.php file located inside your themes directory.

remove_action('admin_notices', 'woothemes_updater_notice');

Display Previous Next Post link at Bottom of Post in WordPress

Displaying previous and next post link at the bottom of the post will make the user to click on that link and check other posts. It also increases the traffic rate. Here is the tutorial for how to display previous next post link at Bottom of Post in wordpress.
This is done by simple coding to be placed in functions.php and style.css and not by installing plugins
WordPress Admin Panel -> Appearance -> Editor -> functions.php
Place the following code inside functions.php file

functions.php

function next_prev_link($link) {
if(is_single())
{
$prev_post = get_previous_post();
if (!empty( $prev_post ))
{
$link .= '<a href="'.get_permalink($prev_post->ID).'" class="prev"><< '.$prev_post->post_title.'</a>';
}

$next_post = get_next_post();
if (!empty( $next_post ))
{
$link .= '<a href="'.get_permalink( $next_post->ID ).'" class="next">'.$next_post->post_title.' >></a>';
}
}
return $link;
}
add_filter('the_content', 'next_prev_link');

WordPress Admin Panel -> Appearance -> Editor -> style.css
Place the following code inside style.css file
style.css

.prev, .next
{
display: block;
}
.prev
{
float: left;
}
.next
{
float: right;
}

How to Create Widget in WordPress using PHP Code

Widget in wordpress will be more helpful for non-developer, widget can be create easily with simple steps. Widgets are the important advantage in wordpress, . Here is the tutorial for how to create widget in wordpress using php code.
function wearecoders_plugin() – this function will create the widget name as “wearecoders Widget”
function form() – this function will be used to display the content to Admin area

function widget() – this function will be used to display the content to visitor area
Add the below coding into your functions.php

class wearecoders_plugin extends WP_Widget
{
function wearecoders_plugin()
{
parent::WP_Widget(false, $name = __('Wearecoders Widget', 'wearecoders_plugin') );
}
function form()
{
echo "<b>This is sample widget</b>";
}
function widget()
{
echo "<b>This is sample widget</b>";
}
}
add_action('widgets_init', create_function('', 'return register_widget("wearecoders_plugin");'));

Fix WordPress asking for FTP details when Installing or Updating

Must Read : Fix WordPress asking for FTP details when Installing or Updating

Most Web hosting are configured to automate installing of theme or plugins. On some hosting WordPress ask for FTP details either to update or install a theme or Plugin.

To fix this issue we can enter our FTP credentials in wp-config.php file so that we don’t have to enter it  every time we update a plugin.

It also helps in new automatic update feature introduced by WordPress.

Enter following code in wp-config.php file.

define( 'FTP_USER', 'username' );
define( 'FTP_PASS', 'password' );
define( 'FTP_HOST', 'ftp.website.com:21' );

Where

  • username is ftp username.
  • password is ftp password.
  • ftp.website.com is ftp hostname and 21 is port number.

Alternatively, We can also override default file and directory permission by entering following lines in wp-config.php

define( 'FS_CHMOD_FILE', 0644 );
define( 'FS_CHMOD_DIR', 0755 );

Where

  • FS_CHMOD_FILE is file permission &
  • FS_CHMOD_DIR is directory permission.

How to redirect to another page in WordPress

Must Read : How to redirect to another page in WordPress

A page can be redirected to a new page or URL. There are different methods to achieve this. In this blog post we will deal with all these methods in details.

Use of these methods depends upon different  use cases. Sometimes HTML redirect work perfectly, in some cases JavaScript or PHP.

There is a WordPress function which can also be used and I think it is best to use WordPress function.

Here are different methods for redirect

HTML Method

In this method we will use meta redirect. Add following code in head section(between <head> and </head>) of your theme header.php .

<meta http-equiv="refresh" content="1; url=http://example.com/" />

Where

http://wearecoders.net is the url where we want to redirect.

JavaScript Method

window.location object can be used to redirect current page URL  to new URL using following code block. Write this block in head area(between <head> and </head>) of header.php

    window.location.href = "http://wearecoders.net"

How to update wordpress robots.txt

Must Read : How to update wordpress robots.txt

Using Google Webmaster Tools or Bing Webmaster Tools you can check if the google bot is able to read your website or if it is disallowed. For some reasons I was having issues with my site a few days ago where my sitemap was not loaded properly by the crawler, sound stupid I know, but was getting errors on this. So I needed to update wordpress robots.txt to include the correct sitemap location, the next day I saw it was all ok. I myself could have manually alter the robots.txt (by the way, if the robots.txt is missing, you will need to create this in the root of your website, along side index.html or index.php), but I remember some online tools that would generate this really fast for me so I used one of them.

Example wordpress robots.txt

WordPress provides a similar sitemap on their documentation page that you can use if you wish, but I don’t really recommend it. It is only an example, nothing else. It shows how you can condition each spider specific to your requirements.

I am currently using the following:

But do keep in mind, wordpress already has a default robots.txt file virtually created (eg. there is no robots.txt file physically), so you will need to create the file manually and add the contents of your robots.txt there.

What can you do with robots.txt

You can control using the robots.txt to only allow specific spiders or restrict other spiders in specific section of your website using the Disallow statement. It is really useful if you do not want certain pages like cache (which should be used by the script only) to be crawled and indexed.

You can also use it to apply conditions only for specific spiders like yahoo or bing.