Search code examples
conditional-statementspreviewexpressionengine

Expressionengine prev next display only 1 category


First of all sorry for my explanations, my tech english is not perfect

Well I have a channel named “blog” connect to different categories inside a group category.

I use an unique template for displaying all entries of all categories, i call it : “article”

Inside the article template, I want to display “preview” and “next” links to navigate through each entry of only one category (ID = 13)

with this code (example with the preview link) it’s working and when i visit a entry belong to the category 13 i see my links and able to navigate

{exp:channel:prev_entry category=“13” } /expressionengine/themes/site_themes/agile_records/images/arrownavleft.png {/exp:channel:prev_entry}

But my problem begin now, this links are also visible in all categories entries i don’t know how hiding these links (preview and next) in the article template for them! the code above is not enough, I try some conditionals with no success

Sorry I am maybe not clear but hard to explain in english


Solution

  • Try wrapping your Prev/Next Entry tag in a conditional so it only displays on entries for category 13.

    I'd use Low Seg2Cat for this.

    {if segment_1_category_id == 13}
      {exp:channel:prev_entry category=“13” }
       ....
      {/exp:channel:prev_entry}
    {/if}
    

    You'll need to set the segment_n_category_id to match the URL segment of your category.