0
我想實現無限滾動到我的網站http://lastmealifetime.com/,從而取代頁面底部的向下箭頭。但是我有一些麻煩。關於如何在我的Wordpress網站上實現無限滾動的任何想法?
我嘗試使用這樣的:
/**
* Load javascripts used by the theme
*/
function custom_theme_js(){
wp_register_script('infinite_scroll', get_template_directory_uri() . '/js/jquery.infinitescroll.min.js', array('jquery'),null,true);
if(! is_singular()) {
wp_enqueue_script('infinite_scroll');
}
}
add_action('wp_enqueue_scripts', 'custom_theme_js');
/**
* Infinite Scroll
*/
function custom_infinite_scroll_js() {
if(! is_singular()) { ?>
<script>
var infinite_scroll = {
loading: {
img: "<?php echo get_template_directory_uri(); ?>/images/ajax-loader.gif",
msgText: "<?php _e('Loading the next set of posts...', 'custom'); ?>",
finishedMsg: "<?php _e('All posts loaded.', 'custom'); ?>"
},
"nextSelector":"#nav-below .nav-previous a",
"navSelector":"#nav-below",
"itemSelector":"article",
"contentSelector":"#content"
};
jQuery(infinite_scroll.contentSelector).infinitescroll(infinite_scroll);
</script>
<?php
}
}
add_action('wp_footer', 'custom_infinite_scroll_js',100);
/**
* If we go beyond the last page and request a page that doesn't exist,
* force WordPress to return a 404.
* See http://core.trac.wordpress.org/ticket/15770
*/
function custom_paged_404_fix() {
global $wp_query;
if (is_404() || !is_paged() || 0 != count($wp_query->posts))
return;
$wp_query->set_404();
status_header(404);
nocache_headers();
}
add_action('wp', 'custom_paged_404_fix');
但是我無法確定正確的CSS選擇器( 「nextSelector」, 「navSelector」, 「itemSelector」, 「contentSelector」)對我特別的主題。
任何人有什麼建議我可以在這裏做什麼?