This may not come up that often but if you are using Get parameters such as lets say submitted by a form to filter some weblog entries, these parameters will not be preserved while using the built in pagination. This can be a real issue if you are trying to filter results and let users page through them but we can add a touch of PHP and fix this issue. In your paginate tags we just need to add the query string to the page link. You’ll notice in the sample we use the server parameter ‘query_string’ along with the question mark which will produce our correct links.

1
2
3
4
5
6
7
8
9
{paginate}
  {if previous_page}
    <a href="{auto_path}<?php echo "?".$_SERVER['QUERY_STRING']; ?>" class='paginate-previous'>Previous</a>
  {/if}

  {if next_page}
    <a href="{auto_path}<?php echo "?".$_SERVER['QUERY_STRING']; ?>" class='paginate-next'>Next</a>
  {/if}
{/paginate}

Comments