I have edited the pages above so they don’t reflect what I wrote.
See this to summarize problem
WordPress automatically adds spaces around shortcodes. So if you don’t set things up perfectly you can often see things like that. Putting this function in your themes functions.php file should fix it.
/**
* Fixes empty <p> and <br> tags showing before and after shortcodes in the
* output content.
*/
function pb_the_content_shortcode_fix($content) {
$array = array(
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']',
']<br>' => ']'
);
return strtr($content, $array);
}
add_filter('the_content', 'pb_the_content_shortcode_fix');
Thank you very much mate 🙂
Your fix did not work, but I have forced the text to have no spaces or breaks between accordion items and now it works.
The text is not so readable now but it works. Since then you have to avoid the visual editor that will rearrange text.
How do you visually code the accordion items? Can you write down a sample?
Thanks again
Here is a sample of how I write them. I do have the function above in my functions.php file as well.
[accordion]
[accordion-item title="First Accordion Item"]
This is item number one.
[/accordion-item][accordion-item title="Accordion item two"]
This is item number two.
[/accordion-item][accordion-item title="Third accordion item"]
This is item number three.
[/accordion-item][accordion-item title="Fourth accordion item"]
This is item number four.
[/accordion-item][accordion-item title="A fifth item"]
This is item number five.
[/accordion-item]
[/accordion]