$venue_type=$_GET['vt'];
$guest_count = $_GET ['gc'];
$area=$_GET['area'];
$keyword=$_GET['s'];
$the_query=newWP_Query();
if($keyword){$taxquerysp[]=array('taxonomy'=>'category','terms'=>$keyword);}
if($keyword){$taxquerysp[]=array('taxonomy'=>'post_tag','terms'=>$keyword);}
$taxquerysp['relationship'] = 'OR';
if($value_type){$metaquerysp[]=array('key'=>'value_type','value'=>$value_type);}
if($guest_count){$metaquerysp[]=array('key'=>'guest_count', 'value'=>$guest_count);}
$metaquerysp ['relationship'] = 'AND';
if($metaquerysp||$area||$keyword){
$query1 = array(
'post_type' = > 'wedding_reports',
'tax_query' = > $taxquerysp,
'meta_query' = > $metaquerysp,
's' = > $keyword
);
$current_articl1 = new WP_Query($query1);
}
I'd like to make the above search possible, but is it possible to search for free words in wordpress and AND in taxonomy and custom fields?
Thank you for your cooperation.
wordpress
AND search is possible.
Function: WP_Query and get_posts extract article data under AND conditions when parameters 'tax_query', 'meta_query', 's' are specified at the same time.
Wordpress is installed in the folder "word"
Custom field abcdef_abc has 'dog'
in articles with a1 set in the category
If you want to narrow down the data where 'cat' exists by searching for free words, you can check it by executing the code below.
require "word/wp-config.php";
$ptype = 'post';
$taxonomyc=
array(array(
'taxonomy' = > 'category',
'field' = > 'slug',
'terms' = > 'a1'
));
$metac=
array(
array(
'key' = > 'abcdef_abc',
'value' = > 'dog',
)
);
$current_articl1 = new WP_Query(array('numberposts'=>5000, 'order'=>'DESC', 'orderby'=>'post_date', 'post_type'=>$pt; $ptype, 'tax_query'=>$taxonomy_', 'gety'='&quater
$pt=get_posts(array('numberposts'=>5000, 'order'=>'DESC', 'orderby'=>'post_date', 'post_type'=>$pttype, 'tax_query'=>$taxonomyc, 'meta_query'=';get>');)
print_r($pt);
Below is the SQL from which the WP_Query function expanded the parameters ($current_articl1->request)
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON(wp_posts.ID=wp_term_relationships.object_id)INNER JOIN wp_postmeta ON(wp_posts.ID=wp_WHEDER=postmeta.post
wp_term_relationships.term_taxonomy_id IN(2)
AND(((wp_posts.post_titleLIKE'%cat%')OR(wp_posts.post_excerptLIKE'%cat%')OR(wp_posts.post_contentLIKE'%cat%')AND(wp_posts.post_password=')AND(
(wp_postmeta.meta_key='abcdef_abc'AND wp_postmeta.meta_value='dog')
AND wp_posts.post_type='post'AND(wp_posts.post_status='publish')GROUP BY wp_posts.ID ORDER BY wp_posts.post_dateDESCLIMIT0,10
© 2024 OneMinuteCode. All rights reserved.