duandazhen7306 2016-09-30 09:30
浏览 59
已采纳

WordPress将p标签添加到插件代码输出中

If I make a page, and in the editor enter one thing, a Slider Revolution shortcode ( [rev_slider alias="grill_accessories"][/rev_slider] ), my slideshow doesn't work. The height is only 48 pixels high for some reason. You can see an example page here: sample slider page

As I inspect the html using Web Developer in Chrome (or FireFox), I notice there are p tags interspersed in and around the <script> code output from the output.class.php file.

For example, here is a code sample function from the output.class.php file which creates a <script> output:

public function add_inline_styles(){

    if(!is_admin()){
        echo '<script>var htmlDiv = document.getElementById("rs-plugin-settings-inline-css"); var htmlDivCss="';
    } 
    else echo "<style>";

    $db = new RevSliderDB();

    $styles = $db->fetch(RevSliderGlobals::$table_css);
    foreach($styles as $key => $style){
        $handle = str_replace('.tp-caption', '', $style['handle']);
        if(!isset($this->class_include[$handle])) unset($styles[$key]);
    }

    $styles = RevSliderCssParser::parseDbArrayToCss($styles, "
");
    $styles = RevSliderCssParser::compress_css($styles);

    if(!is_admin()){
        echo addslashes($styles).'";
            if(htmlDiv) {
                htmlDiv.innerHTML = htmlDiv.innerHTML + htmlDivCss;
            }else{
                var htmlDiv = document.createElement("div");
                htmlDiv.innerHTML = "<style>" + htmlDivCss + "</style>";
                document.getElementsByTagName("head")[0].appendChild(htmlDiv.childNodes[0]);
            }
        </script>'."
";
    } 
    else echo $styles.'</style>';

}

But this is how it looks on output, using the web developer tools inspector:

var htmlDiv = document.getElementById("rs-plugin-settings-inline-css"); var htmlDivCss="";
            if(htmlDiv) {
                htmlDiv.innerHTML = htmlDiv.innerHTML + htmlDivCss;
            }else{
                var htmlDiv = document.createElement("div");
                htmlDiv.innerHTML = "</p>
<style>" + htmlDivCss + "</style>
<p>";
                document.getElementsByTagName("head")[0].appendChild(htmlDiv.childNodes[0]);
            }

I'm far from a WordPress expert, and if I were I would probably not even be asking, but I've tried the

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

...adding it either to the top of my functions.php or to the bottom of my functions.php (there seems to be no clear instruction on where one must add these two lines of code, or maybe it doesn't matter), and it never really works. I've also tried various plugins like Toggle wpautop, but as far as I have ever seen they don't do anything.

  • 写回答

1条回答 默认 最新

  • doukefu1361 2016-09-30 09:34
    关注

    I'm not sure if this is what you're looking for. But you could in that template you wan't to show the slider use a rev slider shortcode for that. So, let's say you have it in frontpage.php then you could display it like this:

    <?php putRevSlider("grill_accessories") ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化