I have a problem updating the WordPress page with custom created shortcode and inserted it?

Help, error status code:

Updating failed. The response is not a valid JSON response.


function register_form_template_f()
{ ?>
    <h1>Hello World! register</h1>


add_shortcode('register_form_template', 'register_form_template_f');
  • 3
    What is WP Gut? Your shortcode is outputting directly to the browser which is very bad, shortcodes must return their HTML as a string yet there is no return statement in your function. By outputting directly to the browser with <?php tags your shortcode will cause lots of problems, such as appearing in the wrong order in content, breaking REST API endpoints used by the post editor, broken RSS feeds, broken nested shortcodes, etc
    – Tom J Nowell
    Commented Aug 30, 2021 at 11:54

1 Answer 1


As Tom pointed out, the reason you are seeing that error is you shortcode is not returning your desired output, but rather outputting it right in place. This results in a breaking of the REST API and you seeing that error message.

Simple fix:

function register_form_template_f() {
    return '<h1>Hello World! register</h1>';

add_shortcode('register_form_template', 'register_form_template_f');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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