Mordar Mordar - 30 days ago 11
PHP Question

WordPress Shortcode Crashes Site

So, to make my story a little short. I'm doing some changes to a client's website, a past freelancer made them a custom theme that made it extremely hard to actually do any changes to the website itself. I'm not that experienced in PHP but I'm learning as I go.

The client asks me to create a slider and I'm using SlideAnything slider plugin that includes shortcodes to be easily added to a page through the editor.

The Shortcode is this "echo do_shortcode("[slide-anything id="2320"]");"

And the way I inserted it in the website was like this:

<section id="feature-courses" class="pt pt-sm-80 feature-section">
<div class="wow fadeInLeft container text-center">
<h2>Cursos de Inglés Destacados</h2>
<div class="spacer-60"></div>
<div class="row">
<?php echo do_shortcode("[slide-anything id="2320"]"); ?>
</div>
</div>
</section>


However, whenever I add it, it crashes the site with a message that says

Parse error: syntax error, unexpected '2320' (T_LNUMBER), expecting ',' or ')' in /home/tuirland/public_html/wp-content/themes/laukoa-tuirlanda/page-homepage.php on line 61

I searched and the shortcodes.php file is inside the WordPress folder.

I recreated my client's website from the ground-up in my local environment and it works flawlessly, however, when I try to do it on his website, the whole thing keeps crashing.

Any reason as to why this is happening on his server but not on my local testing environment? any help would be appreciated. Thanks in advance.

Answer Source

When you using " after the ID atrribute, it's closing the do_shortcode function so it will throw an error. Your code should be:

<?php echo do_shortcode('[slide-anything id="2320"]'); ?>

Or:

<?php echo do_shortcode("[slide-anything id='2320']"); ?>