WordPress Shortcodes

A shortcode that simply returns something

function return_something_shortcode() {
    return 'something';
}

add_shortcode('return_something', 'return_something_shortcode');

Using the shortcode’s content

function use_shortcode_content($atts, $content = null) {
    return $content;
}

Using PHP to execute a shortcode

echo do_shortcode('[return_something]');

Learning Resources

  • Getting Started With WordPress Shortcodes article.
  • How to create your own WordPress shortcodes article.

 

Post A Comment

Anti-Spam Quiz: