English 中文(简体)
使用 if/else 语句无限滚动
原标题:infinite scroll with if/else statement

我试图一次加载3个职位,

So for example, my latest 2 posts have the field (video) filled out, the 3d post has not, the 4th post has. I want post 1, 2 & 4 loaded cause that makes 3. Then infinite scroll should load the next 3 posts that include video, etc.

无限的卷轴工作, 平面查询工作, 但是: 因为第3号后没有填好视频字段, 无限的卷轴只加载 1 & amp; 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>"
}

});

最佳回答
<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-->
问题回答

我之前从未见过 get 函数 。 您知道它从哪个表格中提取数据吗? 如果它是 wp_ postmeta , 您也许可以使用 < a href=> http://codex. wordpress. org/ Class_ Reference/ WP_ uery# Custom_ Fielder_ Paraters > rel= "nofollow" > > 客户字段参数 来获取您感兴趣的数据库记录 。

类似 :

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

应该做这个把戏。





相关问题
Pagination problem

I m using this code for my pagination, and I d like the user s choice to be persistent throughout the site (this has been solved so far)...the only problem now is that the session variable now is ...

mod rewrite problem with 2 parameters

I m trying to rewrite the categoy file of my shop system, I also integrated a pagination so I need to rewrite 2 parameters. it almost works, otherwise I wouldn t be posting in here this is the ...

Issues with pagination in ASP.NET MVC

I am trying to implementation the same pagination that is used in the NerdDinner ASP.NET. I am receiving the following error in my view, whenever the pagination starts to kick in. "A route named ...

Pagination in SQL Server

How do i limit the result of a query (in my case about 60K rows) and select only from the X row to the Y row? If I use ROW_NUMBER() I don t like my query because it involves 2 select queries .. one ...

Cakephp 1.2 Paginator and PassedArgs

Problem: when i have a search resultset with pagination, the links next, prev and numbers do not keep the search parameters. Seems to be a common problem. I searched everywhere on the internet, and ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

热门标签