Want to return all “featured” posts and taxonomy archives to display details from.

This gets all the featured posts:

$args = array(
'post_type' => 'post_type', 
'post_status' => 'publish',
'meta_query'  => array(
            array(
                'key' => 'featured-meta-checkbox',
                'value' => 'yes'
            )
        ),
'fields' => 'id',
'posts_per_page' => -1
);
$query = new WP_Query($args);
// Some HTML
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
// display content
endif; endwhile;
// More HTML

Then I am looping through taxonomy terms

$taxonomies = get_object_taxonomies( (object) array( 'post_type' => 'post_type' ) );
$terms = get_terms( $taxonomy );
foreach( $terms as $term ) : 
    if (get_term_meta( $term->term_id, 'featured-meta-checkbox', true ) == 'yes'):
// Here we can use
    get_cat_name( $term->term_id );
    get_category_link( $term->term_id );
    category_description($term->term_id);

And I can probably even find a way to display the category_thumbnail that the parent theme provides (or use Taxonomy Images).

So I end up with a slider (in this case) displaying featured posts, each with an image, excerpt, title, followed by title, (trimmed) description and probably image for featured categories.

But this approach is inelegant to say the least, and also puts all of the Taxonomy Archives after the featured posts.

There’s got to be a better way, but what is it?

Read more here: Combine Tax Archive and Meta_Query in WP_Query


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: