{"id":244,"date":"2016-08-27T02:47:45","date_gmt":"2016-08-27T02:47:45","guid":{"rendered":"https:\/\/wiki.samuelchopard.ch\/?p=244"},"modified":"2019-03-18T14:29:26","modified_gmt":"2019-03-18T13:29:26","slug":"add-infinite-scrolling-to-your-wordpress-site","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/add-infinite-scrolling-to-your-wordpress-site\/","title":{"rendered":"Add infinite scroll to your WordPress site"},"content":{"rendered":"<p><!--more--><\/p>\n<p>Add the following code to the functions.php of your child theme (<a target=\"_blank\" href=\"https:\/\/samuelchopard.ch\/wiki\/2016\/05\/29\/download-blank-child-theme\/\" target=\"_blank\" rel=\"noopener noreferrer\">download a free blank child-theme here<\/a>).<\/p>\n<h3>Enable Infinite Scroll in Supported Themes<\/h3>\n<p>(try this first)<\/p>\n<pre class=\"EnlighterJSRAW\">add_theme_support( 'infinite-scroll', array(\n'container' =&amp;gt; 'content',\n'footer' =&amp;gt; 'page',\n) );<\/pre>\n<p><strong>You may have to activate infinite scroll in the <a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/jetpack\/\" target=\"_blank\" rel=\"noopener noreferrer\">Jetpack<\/a> plugin.<\/strong><\/p>\n<h3>Enable Infinite Scroll in Unsupported Themes<\/h3>\n<pre class=\"EnlighterJSRAW\">function mytheme_infinite_scroll_init() {\nadd_theme_support( 'infinite-scroll', array(\n'container' =&amp;gt; 'content',\n'render' =&amp;gt; 'mytheme_infinite_scroll_render',\n'footer' =&amp;gt; 'wrapper',\n) );\n}\nadd_action( 'init', 'mytheme_infinite_scroll_init' );\n\nfunction mytheme_infinite_scroll_render() {\nget_template_part( 'loop' );\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3>Infinite Scrolling is Still Not Working<\/h3>\n<p>If you can\u2019t get infinite scrolling to work with the code above, don\u2019t fret! It just means your theme hasn\u2019t been coded like many newer themes to support infinite scrolling.<\/p>\n<p>You may want to check out <a target=\"_blank\" href=\"http:\/\/ottopress.com\/2012\/jetpack-and-the-infinite-scroll\/\" target=\"_blank\" rel=\"noopener noreferrer\">this solution by developer Samuel Wood<\/a>, aka Otto, which explains how to separate your posts from the WordPress loop so you can enable infinite scrolling. It\u2019s a solution that assumes you\u2019re familiar with PHP, so only check it out if you\u2019re comfortable with code.<\/p>\n<p>Source: <a target=\"_blank\" href=\"https:\/\/premium.wpmudev.org\/blog\/how-to-add-infinite-scrolling-to-your-wordpress-site\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/premium.wpmudev.org\/blog\/how-to-add-infinite-scrolling-to-your-wordpress-site\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Add the following code to the functions.php of your child theme (download a free blank child-theme here). Enable Infinite Scroll [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5],"tags":[140,148],"class_list":["post-244","post","type-post","status-publish","format-standard","hentry","category-php-tricks","category-themes","tag-infinite-scroll","tag-jetpack"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/comments?post=244"}],"version-history":[{"count":1,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":54917,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/244\/revisions\/54917"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}