I am trying to debug a shortcode. I have written the following function and placed in my theme's functions.php file:

function michael_function_shortcode() {
    return 'This is the return';

I have defined the shortcode as follows:

add_shortcode(‘michael’, ‘michael_function_shortcode’);

And I have included the shortcode on a page:


I know the function is there because if I introduce errors I get messages because of debug=true, but [michael] just displays and is not replaced by 'This is the return" as expected.

Where do I go from here? How do I debug this?

  • 3
    Is your actual code using quotes like and , or just '? – Jacob Peattie Jun 29 '18 at 3:51
  • 1
    Jacob - Thank you. The single quotes in add_shortcode were not just ' as they should have been. I corrected them and it works fine. I am just using return. Thank you. – mkstlwtz Jun 29 '18 at 4:09

From reading this guide, could you try using a variable to output the return as such?

$output = 'This is the return';
return $output;

Also, if you're calling the shortcode with do_shortcode('[michael]'); in a php file, you'll need to echo this, like so:

<?php echo do_shortcode('[michael]'); ?>
| improve this answer | |
  • The problem was my quotes on the shortcode string. All fixed. – mkstlwtz Jul 2 '18 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.