• Resolved timothy12

    (@timothy12)


    How can I change this query so it only shows posts with the yoast primary category ‘prezi’ or ‘kahoot’?

    <?php
    // the query
    $the_query = new WP_Query(array(
    'post_type' => 'post' ,
    'posts_per_page' => 3,
    'post_status' => 'publish',
    'category_name' => 'prezi, kahoot',
    'orderby' => 'rand',
    'order' => 'asc',
    ));
    ?>

    Kind regards,
    Timothy

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter timothy12

    (@timothy12)

    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',
    ));
    Plugin Support Maybellyne

    (@maybellyne)

    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.

    Thread Starter timothy12

    (@timothy12)

    @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.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adept query’ is closed to new replies.