• I was facing this error on loading the post on scroll when searching page.

    I made debug the problem and found out the cause.. due to not setting “maxPage” option of this plugin.

    By default “maxPage” option setting is “Undefined” which means It doesn’t have any page limitation for post loading. so It will try for loading the page continue on scroll when the page is not found then It will throw the 404 error.

    How to set “maxPage” option :

    We need to make change in “infinite-scroll.php” file of this plugin
    Changes are as follow :

    /**
    	 * Init default options
    	 */
    	function init_defaults() {
    		//option keys map to javascript options and are passed directly via wp_localize_script
    		<strong> $count_posts = wp_count_posts();
    		 $dt = $count_posts->publish;
    		 $pts = get_option('posts_per_page');</strong>
    
    		$this->options->defaults = array(
    			'loading' => array(
    				'msgText'         => '<em>' . __( 'Loading...', 'infinite-scroll' ) . '</em>',
    				'finishedMsg'     => '<em>' . __( 'No additional posts.', 'infinite-scroll' ) . '</em>',
    				'img'             => plugins_url( 'img/ajax-loader.gif', __FILE__ )
    			),
    			'nextSelector'    => '#nav-below a:first',
    			'navSelector'     => '#nav-below',
    			'itemSelector'    => '.post',
    			'contentSelector' => '#content',
    			'debug'           => WP_DEBUG,
    			'behavior'		    => '',
    			<strong>'maxPage' => ceil($dt/$pts)</strong>
    		);
    	}

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

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

  • The topic ‘Getting 404 error in loading posts’ is closed to new replies.