0

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

索引.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(); ?>

内容.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 -->

函数.php

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

2 回答 2

0

我已将 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 更改为您的主题名称。

于 2016-05-21T12:48:37.320 回答
0

添加了 '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
) );
于 2016-05-21T20:13:17.210 回答