Useful WordPress Tricks to be Like a Pro

Continuing our best work and effort to provide readers with best of what we can, Our today article will help bloggers to great extent. Blogging trend is increasing rapidly and hundred thousands of people are earning livelihood from this hobby. I’m naming it’s as hobby, may be or may not you agree but its my opinion as I started blogging as hobby.

You may have met many bloggers that have good reputation in community and are running decent sites, unfortunately they will lack very basic knowledge of programming as they are short of time to get home in tricks. I didn’t mean about all bloggers but probably some new like my friend, sorry friend 😛 Keeping that niche in mind, We decided to collect some very basic tricks and snippets, that can help them mange blog more capably.

Below are some every day demanding snippets and tricks for better WordPress experience.

1- Adding Paypal Donation link

Many of us consider plugin as an easy go thing but that sometimes affects your site opening speed. Also searching suitable and easy to use needs bit more of your time. This doesn’t mean you never use plugins, you should! but try to make them to minimum. A better alternative solution is using short codes.

Paste the below code in functions.php file of your template and don’t forget to replace the default ‘account’ with your paypal email address. Once done, you will be able to show donation link with-in post calling shortcode [donate]

function cwc_donate_shortcode( $atts ) {
'text' => 'Make a donation',
'for' => '',    ), $atts));

global $post;

if (!$for) $for = str_replace(" ","+",$post->post_title);
    return '<a class="donateLink" href="'.$account.'&item_name=Donation+for+'.$for.'">'.$text.'</a>';
add_shortcode('donate', 'cwc_donate_shortcode');

Source: Blue-anvil

2- Calling a Short Code in template file or widget

Sometimes a plugin comes up shortcode support that we can use with-in the post body easily. There may be need to use them in widgets area or in a template file. So here’s a widget solution first. Add the below code into functions.php file of your template to enable support for short codes there!

add_filter( 'widget_text', 'do_shortcode' );

What if we want to use that short code in template files, Here a solution to use them anywhere in template files as well. I’m supposing that you want to execute shortcode [donate] at somewhere in template file. Below is the code to go with with-in the PHP tags:

echo do_shortcode('[donate]');

3- Create Member Only Content

If you want some member only content and not visible to public or guest users, you can use below shortcode trick. Add the below code somewhere in functions.php file of your template.

function member_only_check( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
return $content;
return '';
add_shortcode( 'onlymember', 'member_only_check' );

and you’re done. Now you can create member only content like below

[onlymember]This text will be only displayed to registered users.[/onlymember]

Source: Snipplr

4- Hide/Exclude a Page or a post from Navigation

You can hide any page from navigation bar. i’m assuming that you are using wp_page_menu. To exclude some page from being shown, just pass the args like below:


Here we have excluded three pages with id 5, id 9 and id 23. To know the id of page, goto dashboard > All pages. Point mouse over any post and you will see the id at the bottom of browser showing link.

This was it for now! and yeah sorry folks for below image its for thumbnail thing. We will continue writing articles about programming support to ease our readers work. Follow us @facebook @twitter.

wordpress tricks

About the author

With a passion for Knowledge, Smashinghub has been created to explore things like Free Resources For Designers, Photographers, Web Developers and Inspiration.

Twitter Visit author website

Subscribe to Smashing Hub


  1. Dhafian says:

    Great article..

  2. This is really great.