In Yoast SEO, we could not set the primary category while there is only one category. I needed to get the post where there is if the category is matches and if it was set to primary category, but as while there is only one category, we could not set this as primary but I needed to show this as well.

    $post_args['tax_query'] = array(
        array(
            'taxonomy'         => $taxonomy,
            'terms'            => $term_id,
            'field'            => 'term_id',
            'operator'         => 'IN',
        ),
    );

    $post_args['meta_query'] = array(
        array(
            'key' => '_yoast_wpseo_primary_' . $taxonomy,
            'value' => $term_id,
            'compare'   => '='
        )
    );

thanks for you time

🔴 No definitive solution yet