I've added a shortcode [form] inside my wysiwyg the 2 paragraphes before the shortcode.

<p>test 1</p>



but on the frontend, the shortcode is showing at the top of the content. I thought it was an error in CSS, but the HTML is indead rendering the form, and then my paragraph.

Any idea? I'm on WP 5.4


This is how the shortcode is created :

function form_shortcode() {
    include( "includes/form.php" );

add_shortcode( 'form_calcul', 'form_shortcode' );

I have a few lines of php inside. I should probably precise, I'm in a plugin. I tried also this, but no success:

return ob_get_clean();

1 Answer 1


Before the_content is displayed WP looks for filters to run the content through. One of those filters is do_shortcode. The idea of a filter is that you can change something before it is displayed. As a consequence, if inside the filter function you echo something, it ends up before the_content, which is still waiting for the filtering process to be completed.

Since your function form_shortcode() does not return a modified content anything that is displayed must be the result of echo statements in form.php.

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.