Title: Getting 404 error in loading posts
Last modified: August 21, 2016

---

# Getting 404 error in loading posts

 *  [K.K.Agarwal](https://wordpress.org/support/users/kka284556/)
 * (@kka284556)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/getting-404-error-in-loading-posts/)
 * 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/](http://wordpress.org/plugins/infinite-scroll/)

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

 * ![](https://s.w.org/plugins/geopattern-icon/infinite-scroll.svg)
 * [Infinite-Scroll](https://wordpress.org/plugins/infinite-scroll/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/infinite-scroll/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/infinite-scroll/)
 * [Active Topics](https://wordpress.org/support/plugin/infinite-scroll/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/infinite-scroll/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/infinite-scroll/reviews/)

## Tags

 * [404-error](https://wordpress.org/support/topic-tag/404-error/)

 * 0 replies
 * 1 participant
 * Last reply from: [K.K.Agarwal](https://wordpress.org/support/users/kka284556/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/getting-404-error-in-loading-posts/)
 * Status: not resolved