This snippet shows all posts with their yoast primary category. What do I have to add to get only the posts with the primary category ‘Prezi’ or ‘Kahoot’?
$primary_term = get_post_meta(get_the_ID(), '_yoast_wpseo_primary_category', true);
$the_query = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 3,
'post_status' => 'publish',
'category_name' => $primary_term,
'orderby' => 'rand',
'order' => 'asc',
));
Hello Timothy,
Thanks for reaching out but your question goes beyond the technical expertise of the Yoast support team. Therefore, we can’t give you a solid answer to your question.
But we don’t want to leave you empty-handed. Our developer portal at developer.yoast.com has proven helpful to many developers in the past and hopefully will serve you well too.
Sorry, we can’t be of more help here.
@maybellyne Thanks for your reply and the suggestion for the developer portal. I will think about it. For now, I’ve found a solution that works, but it is not the best one. That would be the adepted query.