This is my template code

{exp:channel:prev_entry channel="events"}
    <a href="{path='events/article'}" title="Previous Offer | {title}">PREVIOUS EVENT</a>

{if '{next}' !='' AND '{prev}' !=''}|{/if}

{exp:channel:next_entry channel="events"}
  <a href="{path='events/article'}" title="Next Offer | {title}">NEXT EVENT</a>

Notice the conditional in the middle {if '{next}' !='' AND '{prev}' !=''}|{/if} I've tried every which way to get this pipe character to only display if there are both a next and a previous entry but not if there is only one of them. I've tried AND XOR OR and also checking for != or == but nothing seems to work. I either get the pipe for all results or it never displays.

What is the correct way to get the pipe character to display only if there are both a next and a previous entry.

2 Answers 2


I'm not seeing a "{prev}" or "{next}" variable listing in the EE 2.5.3 docs for channel entries (I'm assuming you're doing this on a single-entry template).

Have you tried using the {paginate}{/paginate} tag pair? (http://expressionengine.com/user_guide/modules/channel/pagination_page.html)

I'm wondering if something like this will work:

{exp:channel:entries channel="some-channel" sort="desc" limit="1" paginate="bottom"}
    {if previous_page}
        <a href="{auto_path}">Previous Page</a> &nbsp;
    {if previous_page and next_page}|{/if}
    {if next_page}
        <a href="{auto_path}">Next Page</a>
  • Patrick, I'm going to take a look at that. This is an older site that I inherited. Must look closer at the code. Running 2.2.2
    – CreateSean
    Nov 21, 2012 at 15:03
  • 2
    Taking this approach, be sure to disable="member_data|categories|custom_fields" to cut down on overhead. Nov 21, 2012 at 15:09
  • Also note that the pagination tag pair got a LOT more powerful as of 2.3.0, so you might have to upgrade to make this work.
    – adrienne
    Nov 21, 2012 at 15:20

If you want a solution that uses entry linking (rather than pagination as Patrick suggested) then either of these add-ons will allow you to do conditionals based on whether there are next/prev entries or not.

Entry Linking

Advanced Prev Next Entry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.