2015-10-26 88 views
-1

我尝试了所有可能的方式找到googl-ing,但始终没有成功。我想要实现的目标是让PC版本的栏杆始终像移动版本一样。 This是我正在修改的网站。我已经尝试使用body_class('mobile');add_filter()方法。我想添加移动课程,因为我在工作时注意到移动和PC版本之间的变化是该课程以及其他一些我已经能够改变的内容。任何建议。哦,我正在使用的主题是Salient from NectarTheme无法将课程添加到主体

EDIT 1

的header.php类:

<body <?php body_class('test'); ?> data-footer-reveal="<?php echo $footer_reveal; ?>" data-footer-reveal-shadow="<?php echo $footer_reveal_shadow; ?>" data-button-style="<?php echo $button_styling; ?>" data-header-inherit-rc="<?php echo (!empty($options['header-inherit-row-color']) && $options['header-inherit-row-color'] == '1' && $perm_trans != 1) ? "true" : "false"; ?>" data-header-search="<?php echo $headerSearch; ?>" data-animated-anchors="<?php echo (!empty($options['one-page-scrolling']) && $options['one-page-scrolling'] == '1') ? 'true' : 'false'; ?>" data-ajax-transitions="<?php echo (!empty($options['ajax-page-loading']) && $options['ajax-page-loading'] == '1') ? 'true' : 'false'; ?>" data-full-width-header="<?php echo $fullWidthHeader; ?>" data-slide-out-widget-area="<?php echo ($sideWidgetArea == '1') ? 'true' : 'false'; ?>" data-loading-animation="<?php echo (!empty($options['loading-image-animation'])) ? $options['loading-image-animation'] : 'none'; ?>" data-bg-header="<?php echo $bg_header; ?>" data-ext-responsive="<?php echo (!empty($options['responsive']) && $options['responsive'] == 1 && !empty($options['ext_responsive']) && $options['ext_responsive'] == '1') ? 'true' : 'false'; ?>" data-header-resize="<?php echo $headerResize; ?>" data-header-color="<?php echo (!empty($options['header-color'])) ? $options['header-color'] : 'light' ; ?>" <?php echo (!empty($options['transparent-header']) && $options['transparent-header'] == '1') ? null : 'data-transparent-header="false"'; ?> data-smooth-scrolling="<?php echo $options['smooth-scrolling']; ?>" data-permanent-transparent="<?php echo $perm_trans; ?>" data-responsive="<?php echo (!empty($options['responsive']) && $options['responsive'] == 1) ? '1' : '0' ?>" > 

编辑2

我试图在头文件手动设置的类。 ..好吧,即使这样,它也不起作用!我真的不知道该怎么办!

编辑3

好吧,发现菜单中的解决方案,但我仍然无法理解为什么我chenges不工作! (www.youtube.com/watch?v=VzsSTnmGYAQ)

+0

当前'body'标记代码在头文件中看起来像什么?因为你正在为你的身体获得类,可能来自主题开发者添加的代码。 '主页page-id-101 page-template-default自定义背景测试wpb-js-composer js-comp-ver-4.7 vc_responsive' – APAD1

回答

0

您可能试图在header.php文件外设置主体类。

尝试做这样的: php <body <?php body_class('mobile')?>>

+0

不,这就是要点!我已经在header.php文件中完成了这项工作(正如指南告诉我的那样),但没有奏效。 – user3662580

0

的WordPress有body过滤器。在你的functions.php文件,添加:

function body_class_mobile($classes) { 
    $classes[] = 'mobile'; 
    return $classes; 
} 
add_filter('body_class', 'body_class_mobile'); 

这将mobile类添加到您的body标签。根据需要修改条件等。

+0

这也不起作用。我已经尝试过了,但它不会修改主体类 ** P.S。:**不应该是'add_filter('body_class','body_class_mobile');'作为函数的名称? – user3662580

+0

感谢您收到该错字。我修复了它。它看起来像你的链接上添加了你的body类的结尾的移动类' michaelcarwile

+0

还没有。我已经试过了你和Feld Liscia的代码,但它没有奏效。我已经尝试手动设置类,看看它是否会以这种方式改变它们......并且它实际上也是如此。我搜索了所有文件,但没有找到可能导致此问题的文件。 – user3662580