Click the expand icon to open the PHP editor. Within the editor, you can enter PHP functions and custom code or utilize WordPress classes to craft the query. This powerful feature allows for a wide range of query customizations beyond standard options.
You can learn more about queries in WordPress through the WordPress Developer Document for WP_Query
return [
'post_type' => 'post',
'author' => get_the_author_ID()
];
return [
'post_type' => 'post',
'author' => get_post_field( 'post_author' )
];
return [
'post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'terms' => get_queried_object()->term_id
)
)
];
return [
'post_type' => 'post',
'order' => 'DESC',
'orderby' => 'meta_value_num',
'meta_key' => 'date',
'meta_query' => array(
'key' => 'date',
'value' => date('Ymd'),
'type' => 'DATE',
'compare' => '>='
)
];
return [
'post_type' => get_post_type(),
'post_parent' => get_the_ID()
];
return [
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => get_field('acftax'),
'operator' => 'IN',
),
),
];
return [
'post_type' => 'lesson',
'relationship' => [
'id' => 'courses',
'to' => get_queried_object()->ID
],
'orderby' => 'meta_value',
'meta_key' => 'select_2caoexzgghd',
'order' => 'ASC'
];
return [
's' => get_search_query()
];
$taxonomy = get_queried_object()->taxonomy;
$term = get_queried_object()->term_id;
return [
'post_type' => 'any',
'tax_query' => array(
array(
'field' => 'id',
'taxonomy' => $taxonomy,
'terms' => $term,
)
),
];
$taxonomy_name = 'genre'; // enter the name of the taxonomy you would like to filter here
$taxonomy_field = 'slug'; // type the taxonomy field you would like to compare
$term_obj_list = get_the_terms( $post->ID, $taxonomy_name );
$terms_string = join(', ', wp_list_pluck($term_obj_list, $taxonomy_field));
return ['post_type' => 'any',
'tax_query' => array(
array(
'taxonomy' => $taxonomy_name,
'field' => $taxonomy_field,
'terms' => $terms_string
)
)
];