Wordpress Jetpack无限滚动不起作用

时间:2016-05-27 18:07:37

标签: wordpress infinite-scroll jetpack

posts_per_page个帖子中传递不同的functions.php值时,会显示更改,但不会在滚动时加载任何其他帖子。将type更改为click并不会做任何事情。

在functions.php中添加支持:

add_theme_support( 'infinite-scroll', array(
    'type'           => 'scroll',
    'footer_widgets' => false,
    'container'      => 'content',
    'render'         => false,
    'posts_per_page' => false,
) );

index.php

<?php

get_header(); ?>

<div id="content">

    <?php if (have_posts):
        while (have_posts()) {
            the_post(); 
            get_template_part('content', get_post_format()); 
        }   

    else:
        echo '<p>No content found</p>';
    endif; ?>

</div>

content.php

<div class="post clearfix">
<div class="post-heading">
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <h3><a href="<?php the_permalink(); ?>"><?php the_subtitle(); ?></a></h3>
</div>
<div class="post-content">
    <?php the_content(); ?>
    <?php if (is_single()): ?>
        <div class="navigation clearfix">
            <?php the_post_navigation( array(
            'next_text' => 'Next',
            'prev_text' => 'Previous',
            'screen_reader_text' => ' '
            )); ?>
        </div>
        <p><a href="<?php echo site_url(); ?>/blog">Main</a></p>
    <?php endif; ?>
</div>

0 个答案:

没有答案
相关问题