Jetpack无限卷轴-更改帖子数量

时间:2017-03-12 作者:Adam

问题:无法更改Jetpack无限滚动上的帖子数

理想结果:每无限滚动加载10篇文章,而不是默认的7篇

主题:二十五(儿童)

已尝试:

1) 在Jetpack无限滚动菜单中查找设置-没有

2) 将此代码添加到子函数。php

function twenty_fifteen_infinite_scroll_init() {
    add_theme_support( \'infinite-scroll\', array(
       \'posts_per_page\' => 10,
    ) );
}
add_action( \'after_setup_theme\', \'twenty_fifteen_infinite_scroll_init\' );

1 个回复
最合适的回答,由SO网友:Adam 整理而成

在此处找到可用的代码:

https://themeshaper.com/2013/10/08/how-to-override-jetpack-infinite-scroll-settings-in-a-child-theme/

 /*
 * Change the posts_per_page Infinite Scroll setting from 10 to 20
 */
function my_theme_infinite_scroll_settings( $args ) {
    if ( is_array( $args ) )
        $args[\'posts_per_page\'] = 20;
    return $args;
}
add_filter( \'infinite_scroll_settings\', \'my_theme_infinite_scroll_settings\' );

相关推荐