• Resolved Moobs

    (@nickyb713)


    Wpautop is driving me crazy. I’m trying to add some sprite buttons on a page, but it keeps placing <p> tags around my closing anchor tags. This breaks my button links and throws off the flow.

    Link to my page: chump

    I’m at a loss. I’ve tried changing wpautop to false in wordpress, and I have tried changing wpautop and tinymce to false in my theme as well. I have tried a number of plugins, and even tried passing the html through shortcodes and php. Any help would be greatly appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator t-p

    (@t-p)

    Try this filter:

    <?php remove_filter(‘some_function’, ‘wpautop’); ?>

    put this anywhere on your page

    Thread Starter Moobs

    (@nickyb713)

    I placed the remove_filter above the content on my page.php file, but it’s still adding <p> tags.

    <?php remove_filter(the_content(”), ‘wpautop’); ?>

    Thread Starter Moobs

    (@nickyb713)

    [ Moderator note: code block fixed. Please don’t use blockquote for code, it messes with formatting. ]

    This code:

    <div class="book-button-holder"><a href="https://chumptotrader.com/trader-library-encyclopedia-of-chart-patterns/"><div class="chump-review"></div></a><a href="https://www.amazon.com/Encyclopedia-Chart-Patterns-Wiley-Trading/product-reviews/0471668265/?_encoding=UTF8&camp=1789&creative=390957&linkCode=ur2&showViewpoints=1&tag=chutotra-20"><div class="amazon-review"></div></a></div>

    Becomes:

    <div class="book-button-holder"><a href="https://chumptotrader.com/trader-library-encyclopedia-of-chart-patterns/">
    <div class="chump-review"></div>
    <p></a><a href="https://www.amazon.com/Encyclopedia-Chart-Patterns-Wiley-Trading/product-reviews/0471668265/?_encoding=UTF8&camp=1789&creative=390957&linkCode=ur2&showViewpoints=1&tag=chutotra-20">
    <div class="amazon-review"></div>
    <p></a></div>
    Thread Starter Moobs

    (@nickyb713)

    Solved by Arobson13

    I edited the function wpautop() which is located in wp-includes/formatting.php. After some hacking away, I appended the following line of code (line 224):

    $allblocks = ‘(?:a|table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)’;

    As you can see, I added the a tag to the beginning of the string. This function, with the append, will add the p tags and remove them before returning the content string around the block tags listed in the $allblocks string. This will also add a new-line-feed in the source code for the a open and close tag.

    I am glad I was able to post the final fix. I hope this helps someone.

    Solution Topic

    Moderator t-p

    (@t-p)

    Remember you will lose your customizations during the next upgrade.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Help me kill wpautop!’ is closed to new replies.