Skip Navigation

[Resolved] Avoid the disappearance of next/prev in pagination

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to keep the Views pagination Links (previous and next) when you reach the first or last page in the Loop?

Solution:
You can use this HTML Conditional code:

-For the first page:

[wpv-conditional if="( '[wpv-pager-current-page]' eq '1' )"]link[/wpv-conditional]

-For the last page:

[wpv-conditional if="( '[wpv-pager-current-page]' eq '[wpv-pager-total-pages]' )"]link[/wpv-conditional]

This will display a Custom Link when the Views pagination is not deployed (on first and last page)

Make sure the Link you insert, is actually performing some "sensed" action. It should as example present a nice message that there is no more content on the loop.

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/views-pagination/

This support ticket is created 8 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by Angele 8 years, 1 month ago.

Assisted by: Beda.

Author
Posts
#376891

Is there any option to avoid the disappearance of next or previous link in pagination? If you have 3 pages you'll see on Page 1
123 next
on page 2
previous 123 next
on page 3
previous 123

I would like to see on every page
previous 123 next.

Is there a workaround for this?
Thanks in advance

#376945

Well, in my opinion there is something wrong here.

1. We have the option to not show pagination elements if there is only one page

2. Of course if you check that, the pagination will not be displayed if there is only one page generated.

3. But it suggests, if you do not check that option, the pagination will be displayed always, which would actually kind of solve our problem

4. Just, this only works for "dots" and "DropDowns"

5. For links it does not work, they still are not shown

It is of course a logical problem behind this, which actually requires a new feature.

The new feature should be a option "Show pagination but disable it if you are own first or last page"

I am not sure the DEV will implement this but I filed the suggestion.

For now I don't see a valid solution with Views also because even if you could actually display the Pagination Link on last and First page, what would happen if a user clicks on them, while on first or last page?

So for now, you will need a Custom Link, that actually does NOTHING when clicked, or present any error you want.

You can achieve this with this slight conditional in your Filter Section:

[wpv-conditional if="( '[wpv-pager-current-page]' eq '1' )"]link[/wpv-conditional]
[wpv-conditional if="( '[wpv-pager-current-page]' eq '[wpv-pager-total-pages]' )"]link[/wpv-conditional]

Above checks if the current paged page is #1, and #last (total of pages 😉 )

This will help to display links also and only in first and last page.

Thank you

#376975
pagination_with_all.png

Beda,
I centered the pagination and I don't like, that it is jumping on first or last page. Okay, it is a luxury problem, but in my opinion it looks unprofessional.

So. thank you so much for this solution, it works. Below the complete code (I used dashicons as links).
Have a nice sunday, Beda!

[wpv-filter-start hide="false"]
[wpv-filter-controls]
[/wpv-filter-controls]
<div class="paginationcontrols newsgreen">
[wpv-pagination]
  <div class="skipleft">
[wpv-conditional if="( '[wpv-pager-current-page]' eq '1' )"]
<span class="dashicons dashicons-arrow-left-alt2"></span>
[/wpv-conditional]
[wpv-pager-prev-page][wpml-string context="wpv-views"]
    <span class="dashicons dashicons-arrow-left-alt2"></span>
[/wpml-string][/wpv-pager-prev-page]
  </div>
  
  <div class="skippages">
    [wpv-pager-nav-links step="5" reach="2"]
  </div>
  
  
  <div class="skipright">
wpv-conditional if="( '[wpv-pager-current-page]' eq '[wpv-pager-total-pages]' )"]
<span class="dashicons dashicons-arrow-right-alt2"></span>
[/wpv-conditional]
[wpv-pager-next-page][wpml-string context="wpv-views"]
    <span class="dashicons dashicons-arrow-right-alt2"></span>
[/wpml-string][/wpv-pager-next-page]
  </div>
[/wpv-pagination]
</div>
[wpv-filter-end]
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.