I created a custom short code that includes creating an on page table along with a few other things. But the short code is loading in the editor as well, and it is causing errors and preventing me from uploading the page. Is there a way to stop the short code from firing in the editor, or did I improperly code something?
I created a custom short code that includes creating an on page table along with a few other things. But the short code is loading in the editor as well, and it is causing errors and preventing me from uploading the page. Is there a way to stop the short code from firing in the editor, or did I improperly code something?
Share Improve this question edited Aug 6, 2019 at 17:15 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Aug 6, 2019 at 12:39 fwhofwho 1091 gold badge2 silver badges11 bronze badges 4 |1 Answer
Reset to default 0First follow what the codex says Shortcodes. Basically you just wrap your html in ob_start(); this will return the html as a string so you can echo it. 1st way :
function my_shortcode() {
ob_start();
?> <HTML> <here> ... <?php
return ob_get_clean();
}
2nd way
function my_shortcode() {
$output = '';
$output.= '<html>content</html>';
return $output;
}
ob_start()
to capture output, andreturn ob_get_clean()
to return the captured output. – Jacob Peattie Commented Aug 6, 2019 at 14:07