WordPress snippet: breadcrumb without plugin

January 28, 2014 at 7:27 pm

If you want to add a breadcrumb to your blog, you can use one of the many available plugins to do so. But why using a plugin when you can easily code it yourself? Here’s a ready to use code snippet to add a breadcrumb to your WordPress blog.

Open your functions.php and paste the code below in it:

function the_breadcrumb() {
                echo '<ul id="crumbs">';
        if (!is_home()) {
                echo '<li><a href="';
                echo get_option('home');
                echo '">';
                echo 'Home';
                echo "</a></li>";
                if (is_category() || is_single()) {
                        echo '<li>';
                        the_category(' </li><li> ');
                        if (is_single()) {
                                echo "</li><li>";
                                echo '</li>';
                } elseif (is_page()) {
                        echo '<li>';
                        echo the_title();
                        echo '</li>';
        elseif (is_tag()) {single_tag_title();}
        elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
        elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
        elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
        elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
        elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
        elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
        echo '</ul>';

Once done, open header.php and call the function:

<?php the_breadcrumb(); ?>

Thanks to emoticode for this snippet!

ThemeFuse giveaway: 3 premium WordPress themes to win

January 16, 2014 at 6:52 pm

The innovators at ThemeFuse have been generous enough to provide three premium WordPress themes that will be shared with you – our readers! What an exciting way to start your day!

A word about Themefuse

ThemeFuse is one of the most popular actors in the premium WordPress themes market. They provide lots of themes with a great design and solid code.
They have lots of different designs for lots of different needs, so you should definitely have a look to their website!

How to enter the giveaway

Scroll down to the bottom of this very post, and leave a comment for us. Tell us how you would implement your new WordPress theme, and why you should be one of our three winners.

Head over to Twitter and spread the word to your followers about this giveaway by tweeting: Win a free copy of @ThemeFuse #WordPress Theme from @catswhocode (RT to Enter).

Let your Facebook friends know how much you enjoy ThemeFuse by visiting the ThemeFuse Facebook page and clicking the “Like” button.

The three winners will be announced here in one week (January 23, 2014), so stay close!

How to bring back single-column dashboard in WordPress 3.8

December 20, 2013 at 6:06 pm

WordPress 3.8 introduces a new way to display the dashboard. If you don’t like it and would love to bring back the good old single-column dashboard, here’s a quick tip for you.

Bringing back the single-column dashboard in WordPress 3.8 is pretty easy: just add this code to your theme’s functions.php file.

// force one-column dashboard
function shapeSpace_screen_layout_columns($columns) {
	$columns['dashboard'] = 1;
	return $columns;
add_filter('screen_layout_columns', 'shapeSpace_screen_layout_columns');

function shapeSpace_screen_layout_dashboard() { return 1; }
add_filter('get_user_option_screen_layout_dashboard', 'shapeSpace_screen_layout_dashboard');

Thanks to Jeff Starr for the tip!

WordPress trick: load all posts from the current week

December 16, 2013 at 4:38 pm

On some cases, you might want to be able to load and display all the posts from the current week. Here is a handy code snippet to do it easily.

Simply paste the code below where you’d like to load posts from the current week. Then don’t forget to display the results as desired.

$query_args = array(
	'w'    => date( 'W' ),
	'year' => date( 'Y' ),
$posts = get_posts( $query_args );

// display posts as desired

Thanks to Christian Brückner for the tip!

How to automatically add paragraph tags in WordPress

December 5, 2013 at 4:54 pm

By default, WordPress automatically add paragraph tags to the content and the excerpt, using the wpautop() function. If you need to automatically add some <p> tags to any text, you can use the function as shown in today’s example.

In order to add paragraph tags to any text, simply use the wpautop() function, as shown below:

$my_text = 'Lorem ipsum dolor sit amet
consectetur adipiscing elit. 
Nulla pretium libero eget gravida rutrum.';

echo wpautop( $my_text );

Thanks to Daniel Pataki for the tip!

WordPress tip: How to display recently registered users

November 29, 2013 at 7:23 pm

If you allow userregistration on your WordPress blog or website, what about displaying the 5 latest registered users? Here is a simple and efficient recipe to do so.

Simply paste the code below where you want to display recently registered users. This code will display 5 users, you can change this number on line 2.

<ul class="recently-user">
    <?php $usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
        foreach ($usernames as $username) {
                echo '<li>' .get_avatar($username->comment_author_email, 45).'<a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";

Thanks to emoticode for the snippet!!

How to add custom text to WordPress login page

November 25, 2013 at 6:37 pm

If for some reason you need to display a custom message on WordPress login page, here is a quick and easy recipe to do it.

Nothing complicated, paste the code below in your functions.php file. Message can be customized on line 3.

function wps_login_message( $message ) {
    if ( empty($message) ){
        return "<p class='message'>Welcome to this site. Please log in to continue</p>";
    } else {
        return $message;
add_filter( 'login_message', 'wps_login_message' );

Thanks to WP Snippy for the tip!

How to clean up wp_head() without a plugin

November 20, 2013 at 6:10 pm

WordPress adds a lot of stuff through wp_head() hook included in most WordPress themes. Some of this stuff is useful, but some other isn’t. Here’s a quick recipe to clean up the wp_head() easily without using a plugin.

Paste the following lines of code into your functions.php file:

remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'start_post_rel_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );

Thanks to Noumaan Yaqoob for the code!

How to change contents of a dashboard help tab

November 5, 2013 at 5:09 pm

WordPress has a little tab in the top-right corner that, when clicked, drops down some contextual help. Here is a super useful function to hook different help text to different pages.

Simply paste the code below into your functions.php file.

//hook loading of new page and edit page screens

function add_custom_help_page() {
   //the contextual help filter

function custom_page_help($help) {
   //keep the existing help copy
   echo $help;
   //add some new copy
   echo "<h5>Custom Features</h5>";
   echo "<p>Content placed above the more divider will appear in column 1. Content placed below the divider will appear in column 2.</p>";

Thanks to WP Tuts for the tip!

How to disable automatic updates in WordPress 3.7

October 28, 2013 at 4:53 pm

In WordPress 3.7, there’s a new and interesting feature which allow your blog to automatically upgrade when a new version is available. I think it’s really cool, but if you don’t like it for some reason, here’s a quick recipe to turn it off.

To disable automatic updates, open your wp-config.php file and paste the following line in it:


Once you saved the file, automatic updates will be turned off and you’ll have to manually upgrade your blog again.