P text added to html text

前端 未结 3 1579
栀梦
栀梦 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:28

    I had the same problem once, and add_filter( 'the_content', 'wpautop') does not work on my theme. So what I did was the following:

    1. In the revo slider admin area, select the slider that is not displaying well.

    2. Look for the troubleshooting tab (Bottom right) then change the values

    3. Jquery No Conflict Mode = ON

    4. Put JS Includes To Body = FALSE

    5. (Important part) Output Filters Protection = By Compressing Output

    That way, the script will be just in one line therefore the auto paragraph filter will just add the p tag to a single line

    0 讨论(0)
  • 2021-01-19 20:32

    Don´t use inline JS - use register_script() and wp_enqueue_script

    function o99_load_my_scripts()  
    {  
        // Register for a plugin:  
        wp_register_script( 'custom-script', plugins_url( '/js/my-custom-script.js', __FILE__ ) );  
        // or  
        // Register for a theme:  
        wp_register_script( 'custom-script', get_template_directory_uri() . '/js/my-custom-script.js' );  
        // then, you can then enqueue the script:  
        wp_enqueue_script( 'custom-script' );  
    }  
    add_action( 'wp_enqueue_scripts', 'o99_load_my_scripts' ); 
    
    0 讨论(0)
  • 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:
    </p> 
    

    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.

    0 讨论(0)
提交回复
热议问题