The problem is that WordPress keeps adding p tags around each select element and even around the dash character between them. This causes everything to display on separate lines instead of inline. I tried using a plugin called “Disable Visual Editor WYSIWYG” but it didn’t work. What other solutions can I try to stop WordPress from doing this automatic formatting?
You can disable wpautop for specific posts using a custom field. Just create a custom field called ‘disable_wpautop’ and set it to ‘true’ for posts that need raw HTML. Then drop this into your theme’s functions.php:
function conditional_wpautop($content) {
global $post;
if (get_post_meta($post->ID, 'disable_wpautop', true)) {
return $content;
}
return wpautop($content);
}
remove_filter('the_content', 'wpautop');
add_filter('the_content', 'conditional_wpautop');
This way you control wpautop per-post instead of killing it globally. I’ve used this on client sites where only certain pages needed complex HTML forms - keeps auto paragraphs working for regular content.
Wrap your select block in a div with a specific class, then use CSS to force inline display. The real problem is WordPress’s wpautop function - it turns line breaks into paragraph separators. Don’t disable wpautop globally though. Just put all your select elements on the same line in your code with no line breaks between them. Better yet, use shortcodes for complex HTML like this. Create a shortcode function that returns your select elements as one string - WordPress won’t split them up that way. I had the same issue with form elements and shortcodes fixed it completely without messing up other content.
have u tried using the wpautop filter? just add remove_filter('the_content', 'wpautop'); to your functions.php. it should stop those pesky p tags from wrapping your selects. worked for me when i had the same problem!