P text added to html text

前端 未结 3 1623
栀梦
栀梦 2021-01-19 20:02

I know there are a lot of topics on this, and I\'ve already looked at all them and none of the solutions there apply to me.

I\'ve put a shortcode to run a jscript fo

3条回答
  •  半阙折子戏
    2021-01-19 20:41

    A common reason for this is that the theme author changed the priority of the output filters in the theme or even replaced the default ones with his/her own. So, when you insert the Revolution Slider shortcode, paragraph tags are inserter surrounding each line of output, breaking the Javascript code. The usual message in the Firefox error console is:

    Error: SyntaxError: syntax error
    Source Code:
    

    This is a theme problem the theme author should fix. If you want to try to fix it yourself, look for a line like:

    add_filter( 'the_content', 'wpautop' , 99);
    

    and change the priority (the 99) of the filter to something like 9. That may help but also break something else. In some themes the code is not exactly that but you can look for a function adding or removing filters from the shortcodes output. You can see examples in the pages I linked below.

    However, before doing that try this: recent versions of Revolution Slider have an option to avoid being filtered. When you create a slider, in the Troubleshooting box, there is an option named "Output Filters Protection". Enable it (I have used the "By Echo Output" option).

    This is a known problem with some Wordpress themes. Also note, if the theme affected this plugin, it will surely affect other plugins.

    A few comments about this problem are posted in http://pippinsplugins.com/never-remove-the-default-the_content-filters-in-themes/ and http://theandystratton.com/2011/shortcode-autoformatting-html-with-paragraphs-and-line-breaks

    From the first link (Never Remove the Default the_content Filters in Themes):

    There is a terrible, terrible practice among theme developers to remove some of the default filters that are applied to post and page content...

    From the second link (Shortcode Autoformatting HTML with Paragraphs and Line Breaks):

    ... this mysterious issue of my shortcode output being mysteriously auto-formatted with paragraph tags and line-breaks... It’s globally removing two very important core content filters that WP has built-in... This makes this theme work perfectly and negatively affects ANY and ALL plugins that have shortcodes...

    The final solution is the one commented in the second article:

    Don’t use a theme that poor code in it.

提交回复
热议问题