I’ve got this query:
$args = array('category_name' => 'test','posts_per_page' => -1,'relation' => 'AND',
???????'meta_query' ???=> array('relation' ?????=> 'AND',
???????????????array(
???????????????????????'key' ??????=> 'tipus',
???????????????????????'value' ????=> 'music',
???????????????????????'compare' ??=> 'LIKE'
???????????????), ...
???????)
);
Ok, work’s!
But if I change 'music'
for array('music')
and 'LIKE'
for 'IN'
…
$args = array('category_name' => 'test','posts_per_page' => -1,'relation' => 'AND',
???????'meta_query' ???=> array('relation' ?????=> 'AND',
???????????????array(
???????????????????????'key' ??????=> 'tipus',
???????????????????????'value' ????=> array('music'),
???????????????????????'compare' ??=> 'IN'
???????????????), ...
???????)
);
Doesn’t work! :_(
What I’m missing?
Thank’s
]]>$reviews = get_posts([
'post_type' => 'reviews',
'post_status' => 'publish',
'posts_per_page' => 10,
'order' => 'ASC',
'orderby' => 'title',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'schema_review_rating',
'value' => $rating,
'compare' => '='
),
array(
'key' => 'schema_review_rating',
'value' => $rating . '.5',
'compare' => '='
)
)
]);
The goal of the previous query is to retrieve all posts with a rating of 4 or 4.5, and display them ordered by post title. Any suggestions on how to proceed?
]]> <div class="opening-form" id="opening-form">
<?php if( have_rows('account_opening_forms_section') ):
while( have_rows('account_opening_forms_section') ): the_row();
?>
<h5><?php echo the_sub_field("main_heading"); ?></h5>
<div class="opening-form-listing">
<ul class="list-unstyled mb-0">
<?php if( have_rows('account_opening_forms') ):
while( have_rows('account_opening_forms') ): the_row();
?>
<li>
<div class="d-flex justify-content-between align-items-center w-100">
<h4><?php echo the_sub_field("title"); ?></h4>
<a href="<?php echo the_sub_field("download_link"); ?>" target="_blank" class="icon-download"></a>
</div>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
But how can i search this values
my search form is
<form id="search-form" method="POST"> <div class="search-form"> <input type="text" class="search-box form-control" placeholder="Search by form name" name="s" value="<?php echo get_search_query(); ?>"> <a href="javascript:void(0);" class="icon-search" id="formSearch"></a> </div> </form>
‘key’ => ‘event_end’,
‘compare’ => ‘>’,
‘value’ => date(‘Y-m-d’),
‘type’ => ‘DATE’
However, it appears only possible to use the meta query with a static value for comparison. Any pointers? Many thanks.
]]>What causes that and how do I trace it back to the actual query that is sending a null query?
this is meaning that the basket is failing at random and is always empty as you will see (for now) it shows a random string at the top of the basket but no way to tell where that is from. basket is always empty even when things have been placed in it.
Thanks
]]>I’m trying to add a custom meta query to my shop. Whenever I do, the Advanced Labels disappear completely. Why does this happens and how could I go about fixing it? Here’s the custom meta query I’m working with:
add_action( 'pre_get_posts', function( $query ) {
if( is_admin() ) {
return;
}
if( isset( $_GET, $_GET['in_stock'] ) ) {
$meta_query = (array)$query->get( 'meta_query', array() );
$meta_query[] = array(
array(
'key' => '_stock_status',
'value' => 'instock',
),
);
$query->set( 'meta_query', $meta_query );
}
} );
]]>WP_User_Query
:
$args2 = array(
'meta_query' => array(
'gender' => array(
'key' => 'gender',
'value' => 'female',
'compare' => '='
)
),
'number' => 10
);
$user_query = new WP_User_Query( $args2 );
The query is returning unfiltered results, basically ignoring the meta_query
. It works fine if I run it from functions.php
or from a template file, but not from ajax
. Any idea why?
This is the?request
?string when it works:
SELECT SQL_CALC_FOUND_ROWS wp_users.ID
FROM wp_users INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id
)
WHERE 1=1 AND (
( wp_usermeta.meta_key = 'gender' AND wp_usermeta.meta_value = 'female' )
)
ORDER BY user_login ASC
LIMIT 0, 10
And this is the one from the ajax function:
SELECT SQL_CALC_FOUND_ROWS wp_users.ID
FROM wp_users
WHERE 1=1
ORDER BY user_login ASC
LIMIT 0, 10
]]>I have added a custom checkbox group to my directory. I would like to display a list of connections that have a specific value selected. Or, alternatively, group the connections by each option in the checkbox group.
For example, consider the following checkbox group options:
Option A
Option B
Option C
John Doe has Option A and Option B selected.
Jane Doe has Option B selected.
Robert Smith has Option C selected.
Ultimately, what I am trying to display is the following:
Option A
– John Doe
Option B
– Jane Doe
– John Doe
Option C
– Robert Smith
I’m happy to build the Option sections on my page and use multiple shortcodes for each section if necessary.
Thoughts?
]]>only search text for title and descriptión, i need search in all post meta dinamic fields or custom field ej: _custom-text-20
would it be possible to add it here?
add_filter( ‘atbdp_listing_search_query_argument’, function( $args ){
}
]]>Here is the meta query in question :
$meta_key = '_field_date_de_parution';
if (!empty($start) && !empty($end)) {
$meta = array(
array(
'key' => $meta_key,
'value' => array($start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')),
'compare' => 'BETWEEN',
'type' => 'DATE'
)
);
}
I can see that the meta key is indexed in elasticsearch
"meta":{
"properties":{
"_field_date_de_parution":{
"properties":{
"boolean":{
"type":"boolean"
},
"date":{
"type":"date",
"format":"yyyy-MM-dd"
},
"datetime":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss"
},
"double":{
"type":"double"
},
"long":{
"type":"long"
},
"raw":{
"type":"keyword",
"ignore_above":10922
},
"time":{
"type":"date",
"format":"HH:mm:ss"
},
"value":{
"type":"text",
"fields":{
"raw":{
"type":"keyword",
"ignore_above":10922
},
"sortable":{
"type":"keyword",
"ignore_above":10922,
"normalizer":"lowerasciinormalizer"
}
}
}
}
}
}
},
but the search is returning no results if I pass this meta query. It does work without this query and without elasticpress activated (standard wordpress query works just fine).
I’ve added all the code to allow indexing and searching into private meta key, but I can’t get this one to return anything.
]]>