0

通过无限滚动,我尝试一次加载 3 个帖子,但只填写了具有特定字段(视频)的帖子。

例如,我最近的 2 个帖子填写了字段(视频),3d 帖子没有,第 4 个帖子有。我想要帖子 1、2 和 4 加载导致 3 的原因。然后无限滚动应该加载接下来的 3 个帖子,包括视频等。

无限滚动有效,分页查询有效,但是:因为帖子 3 没有填写视频字段,无限滚动只加载帖子 1 和 2,并且不添加帖子 4 来完成我想要的 3 个帖子时间...

我的代码:

<div id="interviews">

<?php   $temp = $wp_query;
        $wp_query= null;
        $wp_query = new WP_Query();
        $wp_query->query('paged='.$paged.'&cat=5&showposts=3');
        while ($wp_query->have_posts()) : $wp_query->the_post();
        echo ('<ul id="infinite">');

    if (get('video_video', 1, TRUE)) {

        echo ('<li class="video">');
        $home = array("h" => 290, "w" => 380, "zc" => 1, "q" =>100);
        //echo get('video_video');
        echo ('With: ');
        echo get('participant_first_name');
        echo ('&nbsp;');
        echo get('participant_last_name');
        echo ('</li>');

        }else{ $video_video=false;
        echo ('');

         }  ?>

        <?php endwhile;?>
       </ul> 

<?php if ($wp_query->max_num_pages > 1) : ?>
<nav id="nav-below">
    <div class="nav-previous"><?php next_posts_link( __( '&larr; More', 'intowntheme' ) ); ?></div>
</nav>

<?php endif; ?>


</div><!--End interviews-->

jQuery脚本:

 jQuery('#interviews').infinitescroll({ 
navSelector  : "#nav-below",  // selector for the paged navigation (it will be hidden)
nextSelector : "#nav-below .nav-previous a",   // selector for the NEXT link (to page 2)
itemSelector : "li.video",  // selector for all items you'll retrieve
extraScrollPx: 50,    
loading         : {
     msgText: "<em>Loading the next year of Grantees...</em>",
    finishedMsg: "<em>You've reached the end of the Grantees.</em>"
}

});

4

2 回答 2

0

我以前没见过这个get功能。你知道它从哪个表中提取数据吗?如果是wp_postmeta,您也许可以在您的数据库中使用自定义字段参数WP_Query来仅检索您感兴趣的记录。

就像是:

$wp_query = new WP_Query();
$wp_query->query('paged='.$paged.'&cat=5&showposts=3&meta_key=video_video&meta_value=1');

应该做的伎俩。

于 2012-05-25T19:52:07.887 回答
0
<div id="interviews">
<?php echo ('<ul id="infinite">'); ?>
<?php 
$wp_query = new WP_Query();
$wp_query->query('paged='.$paged.'&cat=5&showposts=3&meta_key=video_video&orderby=meta_value&order=ASC'  . $post->ID);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php if ( get_post_meta($post->ID, 'video_video', true) ) : ?>
    <li class="video"><?php $home = array("h" => 290, "w" => 380, "zc" => 1, "q" =>100);
            //echo get('video_video');
            echo ('With: ');
            echo get('participant_first_name');
            echo ('&nbsp;');
            echo get('participant_last_name');
            echo ('</li>');?>

<?php endif;?>


<?php endwhile;?>

<?php if (get_post_meta($post->ID, 'video_video', true) ) { ?>
    <?php if ($wp_query->max_num_pages > 1) : ?>
        <nav id="nav-below" >
        <div id="next"><?php next_posts_link( __( 'Scroll down for more', 'intowntheme' ) ); ?></div>
    </nav>
    <?php endif; //end nav ?>
<?php } else {  ?>
<p>There are no interviews at the moment </p>
<?php }   ?>     
</ul>     
</div><!--End interviews-->
于 2012-05-25T22:26:50.540 回答