1
votes

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.

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]');
1
May be shortcode which you trying to implement in your custom theme is in twenty twelve theme. - Vijayakumar Selvaraj
Provide your code here. How you add shortcode in theme ???? - Akshay Paghdar
Sorry,no problem with short code.Problem with script files.No slider plugins are working.I tried with layer slider,wp slider..etc - Manju
Show your code if you want help - Shumail
Updated the question with the code - Manju

1 Answers

0
votes

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.