Skip Navigation

[Resolved] Problem with page shortcodes

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

Problem: The wpv-pager-current-page and wpv-pager-total-pages shortcodes are displaying no values when placed on an archive that only includes one page of results.

<div class="archive-page-more">
Page [wpv-pager-current-page] of [wpv-pager-total-pages]&nbsp;&nbsp;
[wpv-pager-archive-prev-page]
[wpml-string context="wpv-views"]<< Previous[/wpml-string]
[/wpv-pager-archive-prev-page]
&nbsp;&nbsp;[wpv-pager-archive-next-page]
[wpml-string context="wpv-views"]Next >>[/wpml-string]
[/wpv-pager-archive-next-page]
</div>

Solution:
You may wrap your entire pagination section in a wpv-pagination shortcode, which will hide the entire section when there is only one page.

Or, you may add some conditional statements that will display the number 1 when only 1 page is found:

Page [wpv-conditional if="( '[wpv-pager-archive-current-page]' ne '' )" evaluate="false"]1[/wpv-conditional][wpv-pager-archive-current-page] of [wpv-conditional if="( '[wpv-pager-archive-total-pages]' ne '' )" evaluate="false"]1[/wpv-conditional][wpv-pager-archive-total-pages]

Relevant Documentation: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-pagination
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

This support ticket is created 7 years, 4 months 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 7 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#548037

I've got a problem with the shortcodes [wpv-pager-current-page] and [wpv-pager-total-pages]

When they are used in an archive view and that view is only one page only, then the shortcodes do not display a result.

So look to hidden link and they display correctly.

But look to hidden link and they do not display.

The code in each case is the same. Sample code follows;

<div class="archive-page-more">
Page [wpv-pager-current-page] of [wpv-pager-total-pages]&nbsp;&nbsp;
[wpv-pager-archive-prev-page]
[wpml-string context="wpv-views"]<< Previous[/wpml-string]
[/wpv-pager-archive-prev-page]
&nbsp;&nbsp;[wpv-pager-archive-next-page]
[wpml-string context="wpv-views"]Next >>[/wpml-string]
[/wpv-pager-archive-next-page]
</div>

Can you have a look please.

Regards

Robert

#548054

Hi, if you wrap your pagination code with a [wpv-pagination] shortcode, the entire pagination section will only display when there is more than one page of results.

[wpv-pagination]
  <div class="archive-page-more">
  Page [wpv-pager-current-page] of [wpv-pager-total-pages]&nbsp;&nbsp;
  ...
  ...
[/wpv-pagination]

Will this be acceptable?

#548055

Hi Christian

Yes that is okay for my site. Would be nice if the [wpv-pager-current-page] and [wpv-pager-total-pages] returned the value of '1' for a single page. It's a more logical outcome for the shortcode.

Best regards

Robert

#548064

Sure, I see what you mean. If you would like to keep the pagination controls visible and include a "1" for each value, you could set up some conditionals and remove the [wpv-pagination] wrapper:

Page [wpv-conditional if="( '[wpv-pager-archive-current-page]' ne '' )" evaluate="false"]1[/wpv-conditional][wpv-pager-archive-current-page] of [wpv-conditional if="( '[wpv-pager-archive-total-pages]' ne '' )" evaluate="false"]1[/wpv-conditional][wpv-pager-archive-total-pages]