Home Design / Dev Save Time Using Wordpress Shortcodes

    Save Time Using WordPress Shortcodes

    Some repetitive task like twitter code addition in every post may be troublesome for us. There is a simple way that we can do by typing something like [shortcode]. This allowing us to call a php function in any place of the site and saves time. Continue read on to find how to use them.

    Let say we want to add something like an adsense ads in our post, we can use shortcode such as [adsense].

    How it can be done:

    Open your theme’s functions.php file and add this code below:

    - Advertisement -

    [sourcecode language=’php’]

    function showads() {
    return ‘


    add_shortcode(‘adsense’, ‘showads’);

    - Advertisement -


    Just type [adsense] in any place of your post, adsense ads will appear.

    Much simpler example:

    Open functions.php file and add this code below:

    [sourcecode language=’php’]

    function wptidbits() {
    return ‘Have you subscribed to WPTidBits posts today?’;


    Then add this another line below after the above code:

    [sourcecode language=’php’]

    add_shortcode(‘wtb’, ‘wptidbits’);


    Now you are able to use your own [wtb] code as a shortcode. Just paste the shortcode into any place on post (in HTML mode).

    These two are the simplest examples i can give. Surely if you do try using it always and be creative, you will be able to create your own shortcodes. Enjoy!

    - Advertisement -
    Owner of WPTidBits. Totally in love with WordPress!


    Please enter your comment!
    Please enter your name here


    You May Also Like