WordPress.org

Ready to get started?Download WordPress

Forums

Infinite-Scroll
[resolved] need help to set up infinite_scroll (20 posts)

  1. lrrm
    Member
    Posted 1 year ago #

    Hi,

    I've already checked Google and this forum on this topic but I'm stuck.
    Everytime I'm loading the blog with FF (latest) I get this javascript error:

    Error: ReferenceError: infinite_scroll is not defined
    Source File: http://localhost/blog/
    Line: 176

    Let me provide you with some additional information:

    In Line 176 we find the following statement:
    // Because the wp_localize_script method makes everything a string
    infinite_scroll = jQuery.parseJSON(infinite_scroll);

    I'm using this theme, which works fine for me:
    http://wordpress.org/extend/themes/minimalism

    What I already did:
    • I've downloaded and installed the plugin
    • I've activated it
    • modified the header.php to load jquery 1.9.1 and jquery.infinitescroll.min.js (latest from github)
    • I've modfied the functions.php according to this posting
    http://wptheming.com/2012/03/infinite-scroll-to-wordpress-theme/
    to add it manually to the theme
    • according to this thread I've modified line 30x to return true
    http://wordpress.org/support/topic/infinite-scroll-js-error-uncaught-error-infinite_scroll-is-not-defined?replies=15

    The other HTML/JS code looks like this:
    <script type="text/javascript">
    // Because the wp_localize_script method makes everything a string
    infinite_scroll = jQuery.parseJSON(infinite_scroll);

    jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll, function(newElements, data, url) { eval(infinite_scroll.callback); });
    </script>
    <script>
    var infinite_scroll = {
    loading: {
    img: "http://localhost/blog/wp-content/themes/minimalism/images/ajax-loader.gif",
    msgText: "Loading the next set of posts...",
    finishedMsg: "All posts loaded."
    },
    "nextSelector":"#nav-below .nav-previous a",
    "navSelector":"#nav-below",
    "itemSelector":"article",
    "contentSelector":"#content"
    };
    jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll );
    </script>
    <!--stats_footer_test--> <script type="text/javascript">
    (function() {
    var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');

    request = true;

    b[c] = b[c].replace( rcs, ' ' );
    b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
    }());
    </script>

    For me it looks like the JSON object is broken or something.

    Please help me. I' stuck with this.
    Thanks.

    lrrm

    http://wordpress.org/extend/plugins/infinite-scroll/

  2. thisismyalterego
    Member
    Posted 1 year ago #

    To me it seems that you are not using the official infinite-scroll plugin where this discussion is about.
    You are using something different, don't you? Because normally you do not need to "make it work with wordpress" as it is a wordpress plugin.

    What "infinite scroll" script do you use?

  3. lrrm
    Member
    Posted 1 year ago #

    the plugin I've downloaded above. the plug-ins section tells me it is "infinite scroll" Version 2.6.2 | By Beaver6813, dirkhaim, Paul Irish, benbalter, Glenn Nelson

    Isn't this the right plugin?

  4. thisismyalterego
    Member
    Posted 1 year ago #

    And why have you modded your scripts? It's a wordpress plugin that enables infinite scroll. Why did you do modifications like this one:

    http://wptheming.com/2012/03/infinite-scroll-to-wordpress-theme/

    This is only necessary if you want to code your own infinite scroll plugin / method.

    Have you ever tried to use the plugin without modifications?
    Also you should start testing the plugin with one of wordpress default themes (twentytwelve for example) to see if it's running. If it is and not in your theme, your theme needs modifications.

  5. lrrm
    Member
    Posted 1 year ago #

    I modified it because a simple installation did not worked. and as I'm doing this web development stuff for a while (not wordpress, other cm systems)I was looking for the nearest solution: modifying the code on my own.

    I observed that this plugin made not a single modification on html source code. shouldn't there be at least a jquery script?

    you are suggesting that I remove the modifications in the functions php?
    I'll test it with another theme now and let you know if it worked.

  6. thisismyalterego
    Member
    Posted 1 year ago #

    Well, as a developer you should know how things work and how to test things.
    Yes, use a default theme, use the default plugin *without* modifications.
    And you should have noticed that the modifications above are not for the plugin you are using…

    Of course jquery is required, but it's packed right into wordpress.

    If you provide a link to your page (and not localhost…) we could help you way better ;)

  7. lrrm
    Member
    Posted 1 year ago #

    it works more or less with the 2012 theme. scrolling down it show's a loading bar but tells me that there are no more additional posts. unnecessary to say that this is false..

  8. lrrm
    Member
    Posted 1 year ago #

    I'll upload it to a temporary place... testing it on localhost atm. wait a minute...

  9. lrrm
    Member
    Posted 1 year ago #

  10. thisismyalterego
    Member
    Posted 1 year ago #

    alright. But plugin isn't running / configured - is it?

  11. thisismyalterego
    Member
    Posted 1 year ago #

    Ah I see this is the theme that has the problem. Can you switch to twentytwelve theme so I can have a look at the behaviour of the plugin (loading-bar that tells you there are no more posts)

  12. lrrm
    Member
    Posted 1 year ago #

    it is installed and running. the panel gives me only the "deactivate" option...

  13. lrrm
    Member
    Posted 1 year ago #

    hm, I just recognized that the older postings link isn't working...

  14. lrrm
    Member
    Posted 1 year ago #

    it worked before.. of course.

  15. thisismyalterego
    Member
    Posted 1 year ago #

    well… in the backend you have a settings panel - especially for the plugin. This is NOT inside the plugin-panel. It's nested inside of another panel called "settings" or something. Just rollover through the different navigation-menus in the backend.

    When you find it you have to tell the plugins what names your css-selectors have… 
    see here:
    http://www.infinite-scroll.com/

  16. lrrm
    Member
    Posted 1 year ago #

    you are talking about the #content, #nav-below, #nav-below a:first and .post selectors?

  17. thisismyalterego
    Member
    Posted 1 year ago #

    yes - you need to tell the plugin which selector-ids (or class names) your element have… 

    But before you need to fix the usual pagination. I guess you haven't set your permalinks. If these are not set pagination is not working properly.

    I still suggest you try to configure the plugin and everything else with a default theme first. This makes it lots easier to understand how wp and it's plugins work together. Some themes are not using the official structure so you need to re-arrange pluginsettings and code a bit. But therefore it's necessary to understand how they work with a proper theme

  18. lrrm
    Member
    Posted 1 year ago #

    ok, thank you very much :) I think I'll get along from this point :)

  19. thisismyalterego
    Member
    Posted 1 year ago #

    cool :) You can keep me posted if you want.
    Good luck with your page

  20. niente0
    Member
    Posted 7 months ago #

    Hello, I solved modifying footer.php in this way:

    window.onload = function() {
    // Because the 'wp_localize_script' method makes everything a string
    	infinite_scroll = jQuery.parseJSON(infinite_scroll);
    
    	jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll, function(newElements, data, url) { eval(infinite_scroll.callback); });
    };

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.