Hi, I’m try to query post only if in a post object field there is an ID.
I’ve tried with this and similar query but not work.
$query_args = array(
'post_type' => 'post_type',
'posts_per_page' => 10,
'orderby' => 'title',
'order' => 'ASC',
'paged' => $paged
);
if(isset($nome) && $nome) {
$query_args['meta_query'][] = array('key' => 'nome', 'value' => $nome, 'compare' => 'LIKE'); }
if(isset($ref) && $ref) {
$query_args['meta_query'][] = array('key' => 'collegamento', 'value' => '"' . $ref . '"', 'compare' => 'LIKE'); }
I think is possible but I can not find the right code.
Thanks for help!