Query Results Condition for Oxygen

The following code adds a query results condition for Oxygen to your site. It checks if the last query has any results and returns true or false accordingly. It should be placed directly after the Repeater element.

Add the following code to your site using a Code Snippets plugin, such as Code Snippets or WP Code Box (paid).

After you’ve added the condition to the site, you can use the Condition in Oxygen. For example, to display no results found, you can use the following steps:

  • Add a Text element directly below the Repeater element.
  • Edit the text to say “No Results Found”.
  • Finally, set Oxygen’s Conditional Logic to Query Results == false.

snippet Code

if( function_exists(‘oxygen_vsb_register_condition’) ) {

global $oxy_condition_operators;

oxygen_vsb_register_condition(‘Query Results’, array(‘options’=>array(‘true’, ‘false’), ‘custom’=>false), array(‘==’), ‘bitt_query_results_callback’, ‘Query’);

if(!function_exists(‘bitt_query_results_callback’)) {

function bitt_query_results_callback($value, $operator) {

global $wpdb;$query = $wpdb->last_result;
if( $value == “true” && $query) {
return true;
} else if( $value == “false” && !$query) {
return true;
}
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

    Table Of Contents

    Related Content

    © 2020-2024 Luxibay
    Name(Required)
    Please let us know what's on your mind. Have a question for us? Ask away.
    This field is for validation purposes and should be left unchanged.