0
When opening a blog post, I need to pick up all posts, ordered by descending date, that have the same label and are in the same state of the open post. This is OK.
I need to filter more, the category needs to be the same as the post too.
$args = array(
'post_type' => array('post'),
'post__not_in' => $exclude_items,
'posts_per_page' => 4,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'label',
'value' => get_field('label'),
'compare' => 'LIKE',
),
array(
'key' => 'estado',
'value' => get_field('estado'),
'compare' => 'LIKE',
),
)
);
$related_posts = get_posts( $args );
It must be something like this, but I don’t know if it’s right, but it seems to me that get_the_category() returns an array with all categories.
'category_name' => get_the_category(),