When I try to display a shortcode in pages it shows this ‘Updating failed. The response is not a valid JSON response’ error but the page gets updated and no error shows in the frontend. When I use the classic editor it works fine but issues with block editor.
Here its code
<?php
class EmailPluginfront {
function __construct() {
add_shortcode('email', array($this,'front_display'));
}
function front_display() {
echo '<h2 style="text-align:center; margin-bottom:30px">'.get_option('email_title_field').'</h2>';
}
}
$EmailPluginfront = new EmailPluginfront();
2
Answers
you need to return data at the end of your function. try using this in your shortcode function
Can you please use ‘return’ instead of the ‘echo’?