Jump to content

Archived

This topic is now archived and is closed to further replies.

glennyboy

Wpautop Issues with Shortcodes

Recommended Posts

glennyboy    9
glennyboy

Hi

 

For some time I've experienced difficulties with shortcodes within DMS sections having erroneous <p> tags wrapped around elements, often breaking the code or causing conflicts with the correct short code functioning (often requiring a workaround). I've now realised that this is most probably DMS's application of wpautop.

 

It seems that the solution to stopping Wordpress adding wpautop to short codes is adding the following lines to functions.php:-

 

//move wpautop filter to AFTER shortcode is processed
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99);
add_filter( 'the_content', 'shortcode_unautop',100 );

However this doesn't work. I'm guessing this is as I am using a child theme of DMS which is overriding the wpautop settings. Can you please reorder wpautop priority in DMS or advise how to stop DMS wrapping short codes with wpautop.

 

Thanks

 

Glennyboy

 

Share this post


Link to post
Share on other sites
Simon    247
Simon
DMS does not alter any core WordPress filters and shortcodes are not run through wpautop. It all depends where you are adding the shortcodes and what the shortcode is.

If you are adding a shortcode into the post_content area, the actual output of the shortcode isnt run through the filter, but the entire post_content IS and that includes the code that was churned out by your shortcode.

Are you nesting shortcodes?

Share this post


Link to post
Share on other sites
glennyboy    9
glennyboy

It took me some time and numerous attempts to turn off wpautop and/or reorder the wpautop filter on content and shortcodes to determine that DMS absolutely DOES apply wpautop filter on elements and this is within DMS sections like the core TextBox in this line:-

do_shortcode( wpautop($text) ) );

I only found this after exhausting all other avenues and concluding that the issue must lie within DMS itself.

 

To get this back to a standard Wordpress 'do_shortcode' the code can simply be modified to:-

 

do_shortcode( $text ) );

.. and as anticipated no erroneous <p> tags are wrapped round content and short code elements and they work as they should.

 

I appreciate that Textbox would generally dictate a use of formatting so I'm going to make my own section version without the filter,

 

Share this post


Link to post
Share on other sites
Simon    247
Simon
Or put the shortcode in the title field

Share this post


Link to post
Share on other sites

  • Similar Content

    • bnapoli
      By bnapoli+
      On my site www.anewbeginning.com the "toggle" function mysteriously stopped working.  I have tried all browsers, tried disabling plugins, removing all the relevant CSS but still cant understand why it isn't working.
      The toggle is placed on this page: http://anewbeginning.com/?page_id=15965 and http://anewbeginning.com/?page_id=10779 but it does not display.
      On my other Platform5 websites, that exact code works fine: see here http://4aa.d11.myftpupload.com/?page_id=123
      Code is the same. Please help, thank you!
    • micstepl
      By micstepl+
      Pagelines seems to "disallow" the (a) usage and/or (display) of shortcodes.
      Specifically I need shortcodes in "description" of "tag/catagory" in order to display images/fontawsome, before a category.
      Please can you provide a fix for me to allow. 
    • mrhinsh
      By mrhinsh
      Guys,
       The ProPricing plugin does not seam to render shortcodes.

       
      I am using WP-Types, and as you can see the shortcode is rendered in the "Elements" but not in the "ProPricing".
      Can we get a fix?
    • micstepl
      By micstepl+
      @Simon I do have an urgent request for a client Projekt. After migrating (before it worked) my site to anpother Server I get problems will all ShortCode Sections.
      See this Problem here: http://www.baumeister-scheidl.at/map-try
      thanks in advance!
      Maybe ist a User (MY) fault.
    • globalnative
      By globalnative+
      Hi everyone
      I used to love the Pagelines DMS shortcodes for creating tabs and accordians. 
      It doesn't seem to work in this version of pagelines 5?
      Is there another way to get that functional?
      Thank you kindly
      Nate
×