• Resolved cinderalla

    (@cinderalla)


    I have everything working with your plugin. Thank you!

    Just have an annoyance and am wondering if you have any ideas how to fix.

    It appears that WP is adding empty <p> tags around any block level content. I have a number of accordions on a page and find that the ones that just have an image linking to another page are great. But the accordions that have a table for content or paragraph text have two empty paragraphs inserted. One before the content and one after (i.e. <p></p>).

    Trying to fix this, I disabled wpautop, which didn’t work. Also, tried add a test css class to not display <p></p>, which did work. (But, then paragraphs with content that should display don’t…)

    https://www.ads-software.com/plugins/accordion-shortcodes/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author philbuchanan

    (@philbuchanan)

    This is one of those small issues that seems to creep up with WordPress a lot. I have, in past found a few ways to “fix” it.

    The first is to simply remove as many unnecessary line breaks from the editor as possible. If you string all your accordion shortcodes together on one line that can sometimes solve the wpautop issues. Something like this:

    [accordion][accordion-item title=”First”]First block of text.[/accordion-item][accordion-item title=”Second”]Second block of text.[/accordion-item][/accordion]

    That solution isn’t idea for me, as it makes it a pain to update. I sometimes use this code snippet in my themes functions.php file to remove the excess paragraph and break tags:

    /**
     * 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>'   => ']'
    	);
    	$content = strtr($content, $array);
    
    	return $content;
    }
    add_filter('the_content', 'pb_the_content_shortcode_fix');
    Thread Starter cinderalla

    (@cinderalla)

    I agree, that first solution wouldn’t be the best, but the function to remove the “offending” <p> and <br> tags is great! Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Accordion Content Jumps when Opening and Closing Accordion’ is closed to new replies.