0

I'm banging my head here. I can't seem to figure out what's wrong with this it works although if a post has more than two categories is doesn't seem to show. What is wrong here?

<div class="base-column">
                        <button class="accordion">How To&nbsp;&nbsp;&nbsp;<img src="/wp-content/uploads/sites/2/2018/11/expand-button.jpg"></button>
                        <div class="panel">
                            <?php // How To
                            $args_1 = array(
                                'post_type'     =>  'post',
                                'category__and' => array(117,123),
                            );

                            // The Query
                            $the_query_1 = new WP_Query( $args_1 ); ?>

                            <?php // The Loop
                            if ( $the_query_1->have_posts() ) {
                                while ( $the_query_1->have_posts() ) {
                                    $the_query_1->the_post(); ?>

                                    <strong>
                                        <a class="title-article" href="<?php echo the_permalink(); ?>">
                                            <?php echo get_the_title(); ?>
                                        </a>
                                    </strong><br>

                                <?php }
                                /* Restore original Post Data */
                                wp_reset_postdata();
                            } else {
                                // no posts found
                            }

                            ?>
                        </div>
                    </div>
0

You need to edit line 7.

'category__and' => array(117,123),

The category__and parameter doesn't use a string for the category IDs. Write the array like this:

    'category__and' => array(
        '117',
        '123'
    )
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.