【问题标题】:wp functions.php flexslider settingswp functions.php flexslider 设置
【发布时间】:2014-02-22 05:53:22
【问题描述】:

所以,我是 WordPress 的新手。我在functions.php中有这个,它在每个获取页脚的页面上加载脚本:

// flexslider custom settings       
add_action('wp_footer', 'aplace_flexslider_settings');

    function aplace_flexslider_settings() { 
?>          
        <script>
            jQuery(document).ready(function($){

              $('.flexslider').flexslider();

         });            
        </script>

有没有办法自定义它,使其仅在静态首页上调用?例如,我可以制作一个自定义钩子,然后添加到首页,然后在首页上添加 get_customHook 吗?那会取消它与页脚的关联,对吗?我很困惑...

【问题讨论】:

  • 即使有人可以通过抄本或其他东西为我指出正确的方向,我也会非常感激。手抄本现在对我来说就像一个迷宫

标签: javascript php wordpress


【解决方案1】:

只需将函数包装在 if 语句中:

function aplace_flexslider_settings() { 
    if(is_front_page()) { ?>          
        <script>
            jQuery(document).ready(function($){

              $('.flexslider').flexslider();

         });            
        </script>
<?php } } ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    • 2019-08-13
    • 1970-01-01
    相关资源
    最近更新 更多