2012-07-30 94 views
0

我工作的一个网站http://www.matchlessphotography.com已经拿到了照片的理想显示器上 - 这瓷砖的年龄......WordPress的获取帖子AJAX infinate滚动

enter image description here

本质客户想这样下去无穷无尽。

我不知道如何做到这一点,有一看没有任何承载一些教程...


这是我当前如何获取帖子:

<?php 

     global $post; 

     $args = array('numberposts'  => 104, 'meta_key=visible&meta_value=yes'); 
     $myposts = get_posts($args); 
     foreach($myposts as $post) : setup_postdata($post); ?> 

       <a class="photohovera" href="<?php the_permalink(); ?>"> 

       <?php $url = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>    

        <img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<? echo $url ?>&h=138&w=197" width="197" height="138" title="<?php the_title(); ?>" /> 

        <span class="spanno"> 

         <strong class="title_blog_mini_post"> 

         <?php the_title(); ?> 

         </strong> 

        </span> 

       </a> 

     <?php endforeach; ?> 

我想我只需要再次这样做,但每次增加的偏移量......?

回答

0

保罗爱尔兰人jQuery Plugin Infinite Scroll是去这里的路。

该插件寻找分页容器,例如div.navigation以及您要检索的物品的物品容器,例如.photohovera

WordPress提供了一个显示分页链接的功能。它被称为paginate_links,其默认输出应该符合插件的要求。

然而,你将需要改变他们的方式你得到你的帖子,现在从get_posts()到WP_Query对象:

<?php 
$args = array('numberposts'  => 104, 'meta_key=visible&meta_value=yes'); 
$myposts = new WP_Query($args); 
$results = $myposts->get_results(); 
foreach($results as $post) : setup_postdata($post); ?>