Skip to content

Instantly share code, notes, and snippets.

@flyingwebie
Created May 15, 2021 23:09
Show Gist options
  • Save flyingwebie/9fd3a530270927da766a509007302a31 to your computer and use it in GitHub Desktop.
Save flyingwebie/9fd3a530270927da766a509007302a31 to your computer and use it in GitHub Desktop.
Custom WP_Query for EasyPost and Repeater in Oxygen Builder
/* Put this in a code block just BEFORE the repeater */
/* WP_Query Reference: https://github.com/luetkemj/wp-query-ref */
<?php
add_action( 'pre_get_posts', 'custom_query_name' );
function custom_query_name( $query ) {
$cpt_id = get_queried_object_id();
$query->set('meta_query', array(
'key' => 'auction',
'value' => $cpt_id
),
);
$query->set('orderby', 'number');
$query->set('meta_key', 'number');
$query->set('order', 'ASC');
}
?>
/* Put this in a code block just AFTER the repeater if you need to make other queries later on the page */
<?php
remove_action( 'pre_get_posts', 'custom_query_name' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment