Question

I'm trying to build a query that lists posts of a custom type with specific custom field values. Then I need to list children of each of those posts within the post, and those children also need to be filtered by specific custom field values.

Here's my current code, which isn't working. Any help would be greatly appreciated.

Thank you!

<?php
    $args = array(
        'post_type' => 'clients-placements',
        'posts_per_page' => -1,
        'post_status' => 'publish',
        'order' => 'ASC',
        'meta_query' => array(
            array(
                'key' => 'type',
                'value' => 'Client'
            ),
            array(
                'key' => 'featured',
                'value' => 'yes'

            )
        )                       
    );
    $the_query = new WP_Query( $args ); 
    ?>

    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

        <?php get_template_part( 'content', 'clients' );?>

    <ul id="placements">
    <?php
        $args = array(
            'post_type' => 'clients-placements',
            'posts_per_page' => -1,
            'post_status' => 'publish',
            'order' => 'ASC',
            'post_parent' => $post->ID,
            'meta_query' => array(
                array(
                    'key' => 'type',
                    'value' => 'Placement',
                ),
                array(
                    'key' => 'featured',
                    'value' => 'yes',

                )
            )   
        );
        $the_query = new WP_Query( $args ); 

        // The Loop
        while ( $the_query->have_posts() ) : $the_query->the_post();
            echo '<li>';
            the_title();
            the_content();
            echo '</li>';
        endwhile;


    ?>
</ul>   
    <?php endwhile; ?>

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top