{"id":9798505,"date":"2017-12-20T05:08:01","date_gmt":"2017-12-20T05:08:01","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/implementation-tips\/"},"modified":"2017-12-20T05:08:01","modified_gmt":"2017-12-20T05:08:01","slug":"implementation-tips","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/implementation-tips\/","title":{"rendered":"Implementation Tips"},"content":{"rendered":"<p>Great plugin, thanks Scott.<br \/>\nI have very little php knowledge, so it took a while for me to figure out how to implement this properly, but I figured it out (finally) and am posting this for anyone that comes after. My goal was to install it and use it for cycling through posts&#8211; one instance for all posts in the <strong>same<\/strong> category, some in <strong>all<\/strong> categories. Here&#8217;s how I went about it after installing this plugin:<\/p>\n<p>1) I installed the <a href=\"https:\/\/wordpress.org\/plugins\/include-me\/\">INCLUDE ME<\/a> plugin first. This isn&#8217;t necessary if you plan on placing the Looped Nav items into the single.php template, but I was inserting into a Divi text module, and this plugin allows for the retrieval of PHP and other files into page content via shortcode.<\/p>\n<p>2) Set up the code for the version which cycles through the <strong>same<\/strong> category and placed it into a file called infinite-postnav-same-cat.php. Here it is:<\/p>\n<pre><code>&lt;div class=&quot;loop-navigation same-category&quot;&gt;\n    &lt;div class=&quot;alignleft&quot;&gt;\n      &lt;?php c2c_previous_or_loop_post_link( $format=&#039;&amp;laquo; %link&#039;, $link=&#039;%title&#039;, $in_same_term = true, $excluded_terms = &#039;&#039;, $taxonomy = &#039;category&#039; ); ?&gt;\n  &lt;\/div&gt;\n    &lt;div class=&quot;alignright&quot;&gt;\n      &lt;?php c2c_next_or_loop_post_link( $format=&#039;%link &amp;raquo;&#039;, $link=&#039;%title&#039;, $in_same_term = true, $excluded_terms = &#039;&#039;, $taxonomy = &#039;category&#039; ); ?&gt;\n  &lt;\/div&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p>The part that makes it cycle through the same category is changing <strong>$in_same_term<\/strong> to &#8220;True&#8221; in both cases. Other attributes can be changed as needed.<\/p>\n<p>4) Then I linked to that php file through a shortcode from the Include Me plugin:<br \/>\n [includeme file=&#8221;wp-content\/themes\/MyChildTheme\/added-functions\/infinite-postnav-samecategory.php&#8221;]<\/p>\n<p>5) And lastly, placed that shortcode into a text module in a Divi post.<\/p>\n<p>After that, I repeated the process for the version that loops through all categories: Created a php file, named it appropriately, added the code into it, created the shortcode, and then applied the shortcode where I needed it in Divi. The only difference in the version that cycles through all the posts, is that the $in_same_term attribute was changed back to &#8220;false&#8221;. To make this EXTRA easy, here is that version:<\/p>\n<pre><code>&lt;div class=&quot;loop-navigation same-category&quot;&gt;\n    &lt;div class=&quot;alignleft&quot;&gt;\n      &lt;?php c2c_previous_or_loop_post_link( $format=&#039;&amp;laquo; %link&#039;, $link=&#039;%title&#039;, $in_same_term = false, $excluded_terms = &#039;&#039;, $taxonomy = &#039;category&#039; ); ?&gt;\n  &lt;\/div&gt;\n    &lt;div class=&quot;alignright&quot;&gt;\n      &lt;?php c2c_next_or_loop_post_link( $format=&#039;%link &amp;raquo;&#039;, $link=&#039;%title&#039;, $in_same_term = false, $excluded_terms = &#039;&#039;, $taxonomy = &#039;category&#039; ); ?&gt;\n  &lt;\/div&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p>===<br \/>\nLike I mentioned at the start, if you don&#8217;t need to insert the nav links anywhere with shortcodes, then you would skip the part about the Include Me plugin, and the individual php files, and instead take the code I placed in either of the php documents, and paste it into your child theme&#8217;s single.php file where appropriate. Keep in mind though, that with this method, I believe you can only use one of the options (instead of one that works exclusively with categories, and one without).<\/p>\n","protected":false},"template":"","class_list":["post-9798505","topic","type-topic","status-publish","hentry","topic-tag-cycle","topic-tag-post-nav"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9798505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9798505\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9798505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}