Call these methods not earlier than on 'init' with the priority of 12, queries are not registered before that
Returns an array of $id => $name
$queries = \Jet_Engine\Query_Builder\Manager::instance()->get_queries_for_options()
ID is an integer, can be found in query URL in Query Builder;
not to be mistaken with Query ID parameter which is used for JetSmartFilters
$query = \Jet_Engine\Query_Builder\Manager::instance()->get_query_by_id( $query_id );
Returns an array of objects
$query_items = $query->get_items();
$items is an array of objects
$query is an object of class which is an extension of
\Jet_Engine\Query_Builder\Queries\Base_Query
$query->id property is the ID of the query
$query->name is a name of query
see \jet-engine\includes\components\query-builder\queries\base.php for the properties / methods
add_filter( 'jet-engine/query-builder/query/items', function( $items, $query ) {
//if query ID is 128 or query name contains '--filter-result' substring - return post with ID of 256
if ( $query->id == 128 || false !== strpos( $query->name, '--filter-result' ) ) {
$items = array( get_post( 256 ) );
}
return $items;
}, 0, 2 );
add_action( 'jet-engine/query-builder/query/after-query-setup', function( $query ) {
if ( false === strpos( $query->name ?? '', '--current-record' ) ) {
return;
}
$object = jet_engine()->listings->data->get_current_object();
if ( empty( $object->id ) ) {
return;
}
$query->final_query['record__in'] = array( $object->id );
} );
In the last section, it always returns after
Cause "ID" should be higher case.
While I appreciate the code snippets, I wanted to have an option to click on a button and update the listing grid accordingly. I still don't know how to accomplish that. :-(