duandou1903 2014-06-29 01:18
浏览 33

2 wp查询与分页冲突

I have been trying to display a featured post and also the latest posts on the same page but when I go to use pagination, it shows /page/2 in the permalink but it shows the same posts as page 1. I have a feeling the querys are conflicting! How do I fix this please? Code below

     <?php query_posts( array( 
     'post_type' => array('event-', 'videos', 'videos-', 'audio', 'audio-'), 
     'posts_per_page'  => 1,
     'meta_key'        => '_featured',
     'meta_value'      => 'yes'


      )); 
     ?>

      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

        <div class="potdpostcon">

            <div class="featuredimgpotd">
            <a href="<?php the_permalink() ?>"><div class="featuredpostimgzoom"></div><?php the_post_thumbnail( 'featured-post-home' ); ?></a>
            </div>

            <div class="featuredbasepotd">

                <div class="desclrgexcon"><span class="postexplrg"><a href="<?php the_permalink() ?>" class="postexplrg"><?php the_titlesmall('', '...', true, '82') ?></a></span></div>
                <div class="goiconlargecon"><a href="<?php the_permalink() ?>" class="fade"><img src="/wp-content/uploads/2014/06/goicon_lrg.png" /></a>

<?php endwhile; endif; ?>

2nd wp query:

<?php

  $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

  $args = array(
    'post_type' => array( 'post', 'videos', 'videos-', 'audio-', 'event-'),
    'showposts' => 80,
    'paged' => $paged
  );

  $wp_query = new WP_Query( $args );

  if ( have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();?>


      <?php
if( $current_date != get_the_date('d-m-Y') ){
    echo '<div class="datetitle100spc"><div class="datetitleconspc"></div></div><div class="datetitle100"><div class="datetitlecon"><span class="dateheadertitle">'.get_the_date('l dS / M Y').'</span></div></div>';
    $current_date = get_the_date('d-m-Y');
}
?>


<div class="postmainbase">
<div class="postexcon">
                    <div class="featuredimgexcon"><a href="<?php the_permalink() ?>"><div class="postcategoryex"><div class="postcategorytitle"><span class="catexsmall"><?php $category = get_the_category(); echo $category[0]->cat_name; ?></span></div></div><div class="featuredimgzoom"></div><?php the_post_thumbnail( 'home-posts' ); ?></a></div>
                    <div class="sepexcon"></div>
                    <div class="descexcon"><span class="postexp"><a href="<?php the_permalink() ?>" class="postexp"><?php the_titlesmall('', '...', true, '92') ?></a></span></div>
                    <div class="goexcon"><a href="<?php the_permalink() ?>" class="fade"><img src="/wp-content/uploads/2014/06/goicon.png" /></a></div>
                </div>
</div>






            <?php endwhile; ?>

  <div class="paginationdiv">
<?php wp_pagenavi(); ?>
  </div>

     <?php endif; ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题