Support » Plugins » Using Shortcodes on Static Pages?

Viewing 6 replies - 1 through 6 (of 6 total)
  • It is possible to insert shortcodes into post and page.

    If you need more information, you could visit the documentation here.

    http://codex.wordpress.org/Shortcode_API

    Thanks for your answer. I’ve been able to insert them into a post and a page, but this is my homepage and I am not clear how to do this. On this page, I added all the content in the index file, not through the WordPress admin.

    Then you would directly call the function which was registered to the shortcode in your index.php. Example below.

    `
    //[foobar]
    function foobar_func( $atts ){
    return “foo and bar”;
    }
    add_shortcode( ‘foobar’, ‘foobar_func’ );
    `

    Call foobar_func($arg) in your index.php

    Michael

    (@alchymyth)

    Forum Moderator

    to use shortcode in a php template, try

    <?php echo do_shortcode('[wheatevershortcode]'); ?>

    http://codex.wordpress.org/Function_Reference/do_shortcode

    @alchymyth I tried that and for some reason or another it’s not working.

    Michael

    (@alchymyth)

    Forum Moderator

    some things in square brackets are no real shortcodes;

    in this case, try:

    <?php echo apply_filters('the_content','[wheatevershortcode]'); ?>

    if this does not work, please post the real example shortcode and post where the shortcode comes from – plugin or theme or selfmade…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Using Shortcodes on Static Pages?’ is closed to new replies.