WordPress Includes?

Discussion in 'WordPress' started by MrLeN, Jan 10, 2013.

  1. #1
    I know that it's possible to create an include to be used within WordPress.

    ie: I can create the content:

    
    <div class="message">Hello!</div>
    
    Code (markup):
    ..and then, I can call that content from any WordPress page/post using a tag, ie:

    [message]

    But I can't remember where I can create the content for the tag. Can someone please remind me?

    Basically, I want to create an include (or a block of text) that I can simply include anywhere I want with a tag. I know it's possible. I just can't remember how to do it.
     
    MrLeN, Jan 10, 2013 IP
  2. Devtard

    Devtard Notable Member

    Messages:
    850
    Likes Received:
    133
    Best Answers:
    4
    Trophy Points:
    220
    #2
    It is called shortcodes. Use a code similar to the following one in your theme file funcions.php:


    function shortcode_message(){
    return '<div class="message">Hello!</div>';
    }
    
    add_shortcode('message', 'shortcode_message');
    PHP:
     
    Last edited: Jan 11, 2013
    Devtard, Jan 11, 2013 IP