【发布时间】:2018-12-13 10:47:19
【问题描述】:
我正在尝试为我的 Wordpress 网站上的不同页面添加具有不同设置的 jetpack 无限滚动支持。例如,我希望博客页面在您每次向下滚动时重新加载 12 篇文章,并且我希望商店页面每次重新加载 20 个产品。所以我尝试这样做,但它不起作用,不知何故,这些条件被忽略了。
有人知道发生了什么吗?
function quailstudio_infinite_scroll_init() {
if ( is_home() || is_archive() || is_category() ) {
add_theme_support( 'infinite-scroll', array(
'type' => 'scroll',
'container' => 'content',
'wrapper' => false,
'render' => 'render',
'posts_per_page' => 12,
) ); } elseif ( is_shop() ) {
add_theme_support( 'infinite-scroll', array(
'type' => 'scroll',
'container' => 'main',
'wrapper' => false,
'render' => 'render',
'posts_per_page' => 20,
) );
} else { remove_theme_support( 'infinite-scroll','' );
} }
add_action( 'after_setup_theme', 'quailstudio_infinite_scroll_init' );
【问题讨论】:
标签: wordpress if-statement woocommerce conditional infinite-scroll