2012-05-25 45 views
0

隨着無限滾動我試圖一次加載3個職位,但只有填寫具體領域(視頻)的職位。無限滾動與if/else語句

因此,例如,我的最新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>" 
} 

});

回答

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--> 
0

我以前沒見過get的功能。你知道它從哪個表中提取數據嗎?如果它是wp_postmeta,則可能可以在WP_Query中使用custom field parameters,以僅從數據庫中檢索您感興趣的記錄。

喜歡的東西:

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

應該做的伎倆。

+0

嗨,有Hobo, 你是對的!我在幾小時前就明白了這一點,並且工作。我結束了上面的答案... – inTOWN