【问题标题】:Wordpress Jetpack infinite scrollWordpress Jetpack 无限滚动
【发布时间】:2016-05-18 19:58:41
【问题描述】:

我可以显示加载指示器,但没有更多帖子加载。我尝试使用“渲染”和主题名称、模板部分内容而不是 content.php 来做事,将另一个带有 id 的 div 添加到 while 循环中。任何帮助都会非常感谢。

index.php

<?php get_header(); ?>
<div class="tagline">
    <!-- General > Settings > Tagline -->
    <?php echo get_bloginfo( 'description' ); ?>
</div>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php get_footer(); ?>

content.php

<div id="content">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <section class="gallery">

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

            <article class="post-item">

                <?php
if ( has_post_thumbnail()) {
echo '<a href="' . get_permalink($post->ID) . '" >';
the_post_thumbnail( 'thumbnail' );
echo '</a>';
}
?>
<h2 class="post-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="
<?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h2>

 </article>
 <?php endwhile; else: ?>
 <p>
 <?php _e('Sorry, no posts matched your criteria.'); ?>
 </p>
 <?php endif; ?>

 </section>

</article>
</div><!-- content -->

functions.php

add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => 'false'
) );

【问题讨论】:

    标签: wordpress jetpack


    【解决方案1】:

    我已将 functions.php 更改为这个,这样滚动就可以工作了。

    function my_theme_infinite_scroll_render() {
    get_template_part( 'content' );
    }
    add_theme_support( 'infinite-scroll', array(
    'container' => 'content',
    'render'    => 'my_theme_infinite_scroll_render',
    'posts_per_page' => 6,    
    'footer' => 'false'
    ) );
    

    将 my_theme 更改为您的主题名称。

    【讨论】:

      【解决方案2】:

      添加了 'wrapper' => false,以便页面在从帖子返回后完全向上滚动并停止将 /page/2 等添加到 URL。

      还去掉了我为页脚设置的“假”周围的“”,所以现在页脚已经正常了。

      function my_theme_infinite_scroll_render() {
      get_template_part( 'content' );
      }
      add_theme_support( 'infinite-scroll', array(
      'container' => 'content',
      'render' => 'my_theme_infinite_scroll_render',
      'wrapper' => false,
      'posts_per_page' => 6,    
      'footer' => false
      ) );
      

      【讨论】:

        猜你喜欢
        • 2014-11-14
        • 1970-01-01
        • 2016-04-29
        • 2016-09-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-05
        相关资源
        最近更新 更多