Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp query compare like and or

//WP QUERY EXAMPLE WITH MIXED AND & OR in a LIKE comparison
  
$retoArray = array(
  'key'		=> 'reto',
  'value'		=> $data->get_param('reto'), 
  'compare'	=> 'LIKE'
);

$zonaArray = array(
  'relation' => 'OR'
);

//$zonaData = filter_var ( $zonaData, FILTER_SANITIZE_STRING);
//$zonaData = explode(',',$data->get_param('zona-articular'));

foreach($zonaData as $zona){
  array_push($zonaArray,
             array(
               'key'		=> 'zona_articular',
               'value'		=> $zona, 
               'compare'	=> 'LIKE'
             )
            );
}

query_posts(
  array(  
    'post_type' => 'casos-estudio',
    'post_status' => 'publish',
    'posts_per_page' => -1, 
    'orderby' => 'title',  
    'meta_query'	=> array(
      'relation' => 'AND',
      $retoArray,
      $zonaArray
    ),        
  ));
Comment

PREVIOUS NEXT
Code Example
Php :: RouteSubscriber disallow user routes 
Php :: Display random custom content in WooCommerce shop archive loop 
Php :: install php 7.4 amazon linux 2 
Php :: html add div around certain iframe php 
Php :: pass variable in laravel ancher tag laravel 8 
Php :: rename matomo php 
Php :: ubuntu PHP Installation broken - shows strange php code as response 
Php :: php generator for mysql 
Php :: laravel restore deleted 
Php :: php code to display a div with background fade 
Php :: php jwt firebase 
Php :: php switch case 
Php :: implode remove empty php 
Php :: visual studio php dollar sign double click 
Php :: Agregar clases de rol al body en WordPress 
Php :: require_once in class php 
Php :: how-to-add-pagination-in-search-results wordpress 
Php :: backend/web/index.php when deploying 
Php :: $order- date 
Php :: convert any date to db date in suitecrm 
Php :: hou to fill value in input box using php 
Php :: can i do a relation between 2 coulnm in mongodb laravel 
Php :: convert php array into json online 
Php :: How to make a custom helper function, available in every controller for Laravel 
Php :: return multiple rows from mysqli php and encode JSON 
Php :: run url in php 
Php :: how to get count of rows in a table in laravel query 
Php :: pakistan standard time zone 
Php :: comparison of two tables in laravel using model 
Php :: cake php 2.x group 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =