2013-01-18 89 views
1

Jetpack的無限滾動所以我加入他們的無限滾動支持我的functions.php像這樣WordPress的 - 不工作

add_theme_support('infinite-scroll', array(
    'container' => 'content', 
    'footer'  => 'page', 
    'posts_per_page' => 4 
)); 

這裏是我的模板和循環,我添加了一個任意分度的ID「內容'只是因爲jetpack顯然需要你的帖子包含的div是一個ID,但無限滾動仍然無法正常工作。

<?php 


/* 
    Template Name: News 
*/ 

?> 


<?php get_header(); ?> 
<div class="main-content"> 



    <div class="content-left"> 
    <div id="content"> 

     <?php 
     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
     query_posts('posts_per_page=&paged=' . $paged); 
     ?> 


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

    <div <?php post_class('clearfix') ?> id="post-<?php the_ID(); ?>"> 





      <div class="entrywrapper"> 

       <div class="entry"> 




       <div class="bordertop"> 
       <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> 
       </div> <!-- end div bordertop --> 

       <div class="aligncenter grey"> 
       <?php the_time('M jS, Y') ?> 
       </div> 
        <div class="meta"> 


       <span>Posted in :<?php the_category($separator = '/'); ?></span> 
        <div class="clearfix"></div> 
       </div> <!-- end div meta --> 


       <?php global $more; $more = 0; ?> 
       <div class="figure"> 
       <?php the_post_thumbnail(); ?> 
       </div> <!-- end div figure //centers thumbnail --> 


         <p class="firstparaph"> <?php the_field('main_post_meta'); ?></p> 

         <?php the_content('Continue Reading >'); ?> 
         <div class="centerm"> 
         <?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments-link', ''); ?> 
         </div>    
        <div class="postbreaker">* * *</div> <!-- end div entrybreaker --> 
       </div> <!-- end div entry --> 








      <div style="clear:both"></div> 


      </div> <!-- end div entrywrapper --> 

      <div style="clear:both"></div> 

      </div> <!-- end div post --> 




    <?php endwhile; endif; ?> 

     <div class="navigation"> 
      <div class="next-posts"><?php next_posts_link('Older Posts') ?></div> 
      <div class="prev-posts"><?php previous_posts_link('Newer Posts') ?></div> 
     </div> 

    </div> <!-- end div ID content --> 
    </div> <!-- end div content-left --> 

    <div class="content-right"> 
     <?php get_sidebar(); ?> 
    </div> <!-- end div content-right --> 


    <div style="clear:both;"></div> 
</div> <!-- end div main-content --> 
<?php get_footer(); ?> 

回答

0

也許試試這個:

在functions.php的

function get_post_content() { 
?> 
    <div <?php post_class('clearfix') ?> id="post-<?php the_ID(); ?>"> 
     <div class="entrywrapper"> 
      <div class="entry"> 
       <div class="bordertop"> 
       <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> 
       </div> <!-- end div bordertop --> 
       <div class="aligncenter grey"> 
       <?php the_time('M jS, Y') ?> 
       </div> 
       <div class="meta"> 
       <span>Posted in :<?php the_category($separator = '/'); ?></span> 
        <div class="clearfix"></div> 
       </div> <!-- end div meta --> 
       <?php global $more; $more = 0; ?> 
       <div class="figure"> 
       <?php the_post_thumbnail(); ?> 
       </div> <!-- end div figure //centers thumbnail --> 
       <p class="firstparaph"> <?php the_field('main_post_meta'); ?></p> 
       <?php the_content('Continue Reading >'); ?> 
       <div class="centerm"> 
        <?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments-link', ''); ?> 
       </div>    
       <div class="postbreaker">* * *</div> <!-- end div entrybreaker --> 
       </div> <!-- end div entry --> 
      <div style="clear:both"></div> 
      </div> <!-- end div entrywrapper --> 

      <div style="clear:both"></div> 
      </div> <!-- end div post --> 
<?php 
} 

然後在您的博客迴環文件:

<?php 


/* 
    Template Name: News 
*/ 

?> 


<?php get_header(); ?> 
<div class="main-content"> 



    <div class="content-left"> 
    <div id="content"> 

     <?php 
     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
     query_posts('posts_per_page=&paged=' . $paged); 
     ?> 


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

      <!-- MY EDIT IS HERE --> 
      get_post_content(); 

     <?php endwhile; endif; ?> 

     <div class="navigation"> 
      <div class="next-posts"><?php next_posts_link('Older Posts') ?></div> 
      <div class="prev-posts"><?php previous_posts_link('Newer Posts') ?></div> 
     </div> 

    </div> <!-- end div ID content --> 
    </div> <!-- end div content-left --> 

    <div class="content-right"> 
     <?php get_sidebar(); ?> 
    </div> <!-- end div content-right --> 


    <div style="clear:both;"></div> 
</div> <!-- end div main-content --> 
<?php get_footer(); ?>