Short codes are not working in wordpress custom theme

I am developing my own theme,Every thing is working fine,but short codes are not working.

I deactivated my theme and i checked with the twenty twelve theme,here the short codes are working.

Read More

i wrote the following code in index.php

echo do_shortcode('[layerslider id="1"]');

it is not working,even in pages too([layerslider id="1"])

but the following custom shortcode is working

i wrote this code in function.php

function codes()
{
echo "short code working";

}
add_shortcode('codes','codes');

echo do_shortcode('[codes]');

Related posts

Leave a Reply

1 comment

  1. You need to use return not echo in the function. I changed the shortcode name so it is different to the function name in this example.

    Try this:

    functions.php

    function codes() {
    return 'Short code is working';
    }
    
    add_shortcode('codeworks','codes');

    index.php

    echo do_shortcode('[codeworks]');

    On the twenty twelve theme shortcodes you need to make sure you copy them into the new theme you are building.

    Hope it helps.