6
votes

Everytime i try to add a shortcode into my Wordpress site it ends up merely displaying the code i add to the actual page. I've been pasting the code into the "text" area of the content section but still doesnt work.

Even when I paste inside of the header.php file I recieve the same result. For example.

I recently copy pasted the following code in header.php (as instructed by the plugin i downloaded) <div class="headerslider"> <?php echo do_shortcode('[sp_responsiveslider limit="-1"]'); ?></div>

When I save a reload, I just get [sp_responsiveslider limit="-1"] appear in my website. This happens with all shortcodes i do.

Please help

1
You are adding the above to a post/page? - Howli
Im adding it to a page - Mesbah Jamali
Your code is correct and should be working so we would need more informations to help you. Do you have a link to the page? How exactly do you integrate the php code? With a text editor? Where do you integrate your code in your header.php? - Kimberley Furson
@MesbahJamali, have you tried adding it without the php code? So only add <div class="headerslider">[sp_responsiveslider limit="-1"]</div> to the page. - Howli
@KimberleyFurson Please note that I only used that as an example. Its with any shortcode i use. But for this example, i tried adding it to the very end of the header.php, then within the header section, also at the start of the body section. Here is a link to the plugin Im using. wordpress.org/plugins/responsive-header-image-slider Note that it says "You can also use this image slider inside your page with following shortcode [sp_responsiveslider limit="-1"]." Ive tried this but it doesnt work aswell - Mesbah Jamali

1 Answers

9
votes

It seems like the shortcode sp_responsiveslider isn't actually defined. Are you sure the plugin is installed correctly? If the plugin is installed correctly you can test to see if shortcodes are working on your WordPress installation. Paste the following in your functions.php file (add <?php to the first line if it's not already in the file):

function test_shortcodes()
{
    return 'Shortcodes are working!';
}
add_shortcode('test_shortcodes', 'test_shortcodes');

This will create a new shortcode in WordPress. To test if shortcodes are working put the text [test_shortcodes] within a post and view the page with the post. When you load the page the shortcode tag should be replaced with "Shortcodes are working!". If this works, there is an issue with the plugin and it's shortcode.

If the test text is not displayed there might be a problem with your WordPress installation.