We have a blog section on our website that displays 10 entries per page however, when you click next page or '2' it returns an empty page.

From what I can see the code is the same as for our news page and that's working fine. I've looked through similar issues on the forums but can't find a fix that works.

The code for the entries is:

{exp:channel:entries channel="blog" orderby="date" paginate="bottom" limit="10" {if segment_2}author_id="{segment_2}"{/if}  dynamic="no"}

And the code for the pagination is:


<p class="pagination">Showing page {current_page} of {total_pages} <span>{pagination_links}</span></p>

Can anyone see what would be causing the issue?

Let me know if there's any more info you'd need.

1 Answer 1

{if segment_2}author_id="{segment_2}"{/if}

There's your problem. After you click on a pagination link, {segment_2} becomes P10, P20, etc. So you're looking for all entries by the member with the ID of P10.

You're better off making an author template to filter entries by author, where you can have a more predictable segment to hold the member ID and still use pagination.

  • Thanks Derek, I hadn't realised that was what that related to, I'm sure it hadn't caused an issue until recently though which seems strange. I've changed the author_id to {segment_3} and amended the code for the authors section to the following {exp:top_authors channel="blog"} <li><a href="/blog/author/{author_id}">{name} ({count})</a> </li> {/exp:top_authors} adding in the /author/ segment after the /blog/ and this has fixed the issue, pagination works and the author filter works. Do you think writing it like this could cause any other issues? Commented Dec 17, 2015 at 16:39
  • That looks right to me! Commented Dec 17, 2015 at 16:57

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.