Hi guys,
I’m wanting to modify some of my GD queries using pre_get_posts and a custom field value but I realized the custom fields are stored in their own tables related to their CPT.
Here’s the code I have so far:
/*-------------------------------------------------------------------------------
Show More Posts Per Page & Filter Out Sold Listings
-------------------------------------------------------------------------------*/
function show_more_posts($query) {
if ( empty( $query->query_vars['suppress_filters'] ) ) {
if( geodir_is_page('listing') || geodir_is_page('author') || geodir_is_page('search') ) {
$query->set( 'posts_per_page', -1 );
$query->set( 'meta_query', array(
'relation' => 'OR',
array(
'key' => 'geodir_is_sold',
'value' => 1,
'compare' => '=',
'type' => 'BINARY'
),
array(
'key' => 'geodir_is_sold',
'compare' => 'NOT EXISTS',
'value' => 'completely'
)
)
);
}
}
return $query;
}
add_filter( 'pre_get_posts' , 'show_more_posts' );
Do you guys know how I could modify the query in the way I’m try to?