dqwh1203 2017-12-12 21:57
浏览 15
已采纳

如何从第一个博客页面以外的博客页面隐藏滑块?

How I can hide top slider in Wordpress form my 2,3,4... blog page with php? This is my script:

<section id="blog">
       <div class="owl-carousel">
          <?php $loop = new WP_Query(array('post_type' => 'post', 'posts_per_page' => -1, 'orderby'=> 'ASC')); ?> 
          <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
             <div class="recent-post">
                <div class="home-slider-img">
                    <?php echo the_post_thumbnail(); ?>
                </div> 
                <div class="feat-overlay">
                    <div class="feat-overlay-inner"> 
                        <div class="post-header">                     
                            <span class="cat"><?php the_category(', ') ?></span>
                            <h4><a href="<?php the_permalink(); ?>"><?php print get_the_title(); ?></a></h4>
                            <span class="date"><?php the_time('M j, Y') ?></span>
                            <p><a class="read-more" href="<?php print get_permalink($post->ID) ?>">Read More</a></p>
                        </div>      
                    </div>  
                </div>
            </div>
          <?php endwhile; ?>
       </div>
    </section>
  • 写回答

1条回答 默认 最新

  • dongsao8279 2017-12-12 22:50
    关注

    The is_home() function should do what you want - https://developer.wordpress.org/reference/functions/is_home/

    Just wrap your owl-carousel div in an if test to check if you're on the blog homepage like this:

    <?php if (is_home()) { ?>
         <div class="owl-carousel">...</div>
    <?php } ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?