Skip Navigation

[Resolved] Make Feature Products appear only on First Page of Pagination

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

Problem:

The issue here is essentially the user wanted to get the current page number of his archive.

Solution:

We can do this with a very simple custom shortcode, add the following to your functions.php file

// Add Shortcode
function current_page() {
 
     return get_query_var('paged');
 
}
add_shortcode( 'current_page', 'current_page' );

Then you can use this to get the current page number [current_page]

This support ticket is created 7 years, 2 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 6 replies, has 2 voices.

Last updated by johnH-21 7 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#576184

We are attempting to showcase 4 Featured Products on the top our WordPress View Archive however have it only display on the first page of the pagination.

We didn't know what conditional output / function we would use to obtain such results.

We believe we have created everything necessary to showcase the featured products however just need to find a solution to showcase the Featured Products only on the first page of the archives.

Thank you for your continued support!

#576224

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

Thank you for contacting our support forum.

In order to best advise on this I would like to know how are you doing the current setup.

Thanks,
Shane

#576236

Thanks for the quick response Shane.

First we created a Custom Post Field that is a checkbox of whether the product is featured or not.

We then created a view that has a custom field filter for just featured products and the styling we wanted via the loop output editor and CT.

We then called the view inside our WordPress Archive outside of the loop in the Loop Output Editor. It works great with using the filtering of the wordpress archive and displays properly however we just want it to display on the first page of the pagination on the WordPress Archive not the subsequent pages thereafter.

Let me know if I can provide additional information or screenshots that might be beneficial.

Best Regards,

#576245

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

Thanks for the information.

We may be able to achieve this with the conditional shortcode but I need to take a look at the page.

Would you mind providing me with a link to the page ?

Thanks,
Shane

#576249

hidden link

#576259

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

Could you try adding this to your functions.php file

// Add Shortcode
function current_page() {

	 return get_query_var('paged');

}
add_shortcode( 'current_page', 'current_page' );

It will generate a shortcode that should give you the current page number of the archive. The shortcode is [current_page]

Please try this and let me know if it returns a result.

Thanks,
Shane

#576272

Worked great!!

Thank you!