snipt

Ctrl+h for KB shortcuts

PHP

Display Post Divider Between Posts

1
2
3
4
5
6
7
<?php
if (($wp_query->current_post + 1) < ($wp_query->post_count)) {
   echo '<div class="post-item-divider">Post Divider</div>';
}
?>

//Found at: http://css-tricks.com/snippets/wordpress/post-divider/
https://snipt.net/embed/cd27e13121f5b36b8fc31ec2bdacf3d6/
/raw/cd27e13121f5b36b8fc31ec2bdacf3d6/
cd27e13121f5b36b8fc31ec2bdacf3d6
php
PHP
7
2019-05-23T12:42:17
True
False
False
Jan 21, 2013 at 08:13 AM
/api/public/snipt/54135/
display-post-divider-between-posts
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="k">if</span> <span class="p">((</span><span class="nv">$wp_query</span><span class="o">-&gt;</span><span class="na">current_post</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">&lt;</span> <span class="p">(</span><span class="nv">$wp_query</span><span class="o">-&gt;</span><span class="na">post_count</span><span class="p">))</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">echo</span> <span class="s1">&#39;&lt;div class=&quot;post-item-divider&quot;&gt;Post Divider&lt;/div&gt;&#39;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span><span id="L-5"><a name="L-5"></a><span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="x">//Found at: http://css-tricks.com/snippets/wordpress/post-divider/</span> </span></pre></div> </td></tr></table>
styling, wordpress