12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Dec 24, 2019

Archive Pagination Condition in Oxygen

David Browne

Sometimes we have a lot of content above the posts on paginated archive pages. Archive title, archive description, maybe a call to action etc. When the user clicks to view the next page of posts, we may not want to show them all that content again on the 2nd, 3rd page.

We can use Oxygen’s conditions feature to show/hide all that content based on what page the user is on.

This isn’t a condition that comes built-in out of the box, but we can register our own.

Register Our Pagination Condition

We place this is our code snippets.

if( function_exists('oxygen_vsb_register_condition') ) {
	global $oxy_condition_operators;

	oxygen_vsb_register_condition('Page #', array('custom' => true), $oxy_condition_operators['int'], 'condition_paged_callback', 'Archive');


function condition_paged_callback($value, $operator) {
	$value = intval($value);
	$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

	return oxy_condition_eval_int($paged, $value, $operator);

The condition will appear inside Oxygen under the Archive heading.. I named it ‘Page #’.

The condition checks to see if the number we enter matches the current page the user is on.

In the example above you can see we have set the Page number to equal 1. That means this element will only show on the first page of the archive. When the user clicks to the next page /blog/page/2/ or /blog/page/3/ etc they won’t see this content.

All done

This is especially useful if your posts page is set as your home page and you have lots of sections above posts with pagination. It prevents the user from needing to scroll down past all that content just to get to the posts.