Infinite Scroll help needed
-
Im using a custom theme, built with “Blank State.”
I’ve added the required code to Activate the Infinite Scrolling to the functions.php file.. however, no scrolling happens!
Site im working on is located here:
http://www.gd-gaming.com/wordpressThanks
-
Could you point me to the page listing all your blog posts, as set under Settings > Reading in your dashboard?
Thanks!
The Front Page is set to: “Home” and this contains the post loop.
I dont have a “Post-Page” set as I’ve completely customized the theme.
If you take another look, I’ve gotten masonry to work with what im doing.. However, Infinite-Scroll I am having no luck.
Is this something I’m going to need to put in without jetpack since everything is customized?
Ok, I see you have now switched to your custom theme. I can see the posts now.
Infinite Scroll will only work on your Posts page and on archive pages (ref).
If you want Infinite Scroll to be loaded on your static front page as well, you will have to add Infinite Scroll support to
is_front_page().To do so, you can add the following code to your theme’s functions.php file:
function tweakjp_custom_is_support() { $supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_front_page() ); return $supported; } add_filter( 'infinite_scroll_archive_supported', 'tweakjp_custom_is_support' );Once you’ve done so, you can follow this tutorial to make sure Infinite Scroll works with JS Masonry:
http://wptheming.com/2013/04/jetpack-infinite-scroll-masonry/Awesome, I’ve added the above function.. However, still no luck.
I’m curious as to if me not having pagination has anything to do with new elements not loading?
Or.. Could it be my post loop?
Or… Do I simply need to follow the link you’ve provided?Heres the top portion of my loop:
global $more; $more = 0; query_posts('cat=7,8,9,10&posts_per_page=15' ); if (have_posts()) : while (have_posts()) : the_post(); ?>In any case, I really appreciate the help my friend. I’ve been at this for a day or so to no avail and your help is truly appreciated.
I’m curious as to if me not having pagination has anything to do with new elements not loading?
This can be caused by different factors, like the number of posts, whether you added pagination links or not, or your jQuery Masonry settings.
You should be able to get things working with the tutorial I mentioned in my last post.
As a sidenote, I would recommend that you use
WP_Queryinstead ofquery_poststo build your loop. You can read more about it here:
http://developer.wordpress.com/2012/05/14/querying-posts-without-query_posts/I’ve added the correct pagination, removed the post feature. Still with no luck.
Where exactly do I place the code from the tutorial that you posted to get it worked with masonry? Does that go in functions.php?
Additionally, I removed the Masonry script to see if that was interfering, infinite scroll still did not load additional posts.
I may have located the issue: When turning on the debugger, heres what I was greeted with:
`
Notice: Undefined property: WP_Query::$post in /home4/aa/public_html/wordpress/wp-includes/query.php on line 3017Notice: Trying to get property of non-object in /home4/aa/public_html/wordpress/wp-includes/query.php on line 3385
Notice: Trying to get property of non-object in /home4/aa/public_html/wordpress/wp-includes/query.php on line 3387
Notice: Trying to get property of non-object in /home4/aa/public_html/wordpress/wp-includes/query.php on line 3389
Notice: Undefined property: WP_Query::$post in /home4/aa/public_html/wordpress/wp-includes/query.php on line 3017
You’ll probably need to edit your Post query to solve this issue. You can find a lot of examples on this Codex page:
http://codex.ww.wp.xz.cn/Class_Reference/WP_QueryThat seems to have led me on the right track, thanks my friend!
I see you’ve tried to use Infinite Scroll with Masonry, but still experience issues.
You used the code provided in the tutorial I linked to earlier, but I still see some Javascript errors when browsing your site. These errors seem to be created by Masonry:
http://i.wpne.ws/QYDgYou’ll want to make sure that jQuery Masonry is correctly called on your site.
Alright heres what I have.
header.php (Placed above the body tag)
<script> jQuery( document ).ready( function( $ ) { infinite_count = 0; // Triggers re-layout on infinite scroll $( document.body ).on( 'post-load', function () { infinite_count = infinite_count + 1; var $container = $('#content'); var $selector = $('#infinite-view-' + infinite_count); var $elements = $selector.find('.hentry'); $elements.hide(); $container.masonry( 'reload' ); $elements.fadeIn(); }); }); </script>functions.php
function my_masonry() { if (!is_admin()) { wp_register_script('jquery_masonry', get_template_directory_uri(). '/js/jquery.masonry.min.js', array('jquery'), '2.0.110526' ); wp_enqueue_script('jquery_masonry'); add_action('wp_footer', 'add_my_masonry'); function add_my_masonry() { ?> <script> jQuery(document).ready(function($){ $('#content').masonry({ itemSelector: 'article', }); }); </script> <?php } } } add_action('init', 'my_masonry');Do you see any issues within either of these?
Or am I calling the script in the header incorrectly?You seem to be using a different code on your site at the moment. I do not see any mention of the first code snippet, and the code you created via the
add_my_masonryis different, and does seem to be loaded beforewp_footer.Could you make sure the code you mentioned above is added properly?
Sorry, I was messing around and tried something different.
Everything is back in place, again.. I really appreciate you helping me to resolve this.
I don’t seem to be able to access your site at the moment. Could you let me know once it’s back up?
You might also want to switch to the Twenty Twelve and add only the jQuery Masonry to that theme, since it already supports Infinite Scroll.
The topic ‘Infinite Scroll help needed’ is closed to new replies.