Get posts for last working week in WP_Query

Well, try the below code- $base_array = array( ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘post_type’ => ‘cpt’, ‘post_status’ => array(‘publish’), ‘date_query’ => array( ‘after’ => strtotime( ‘previous week Monday’ ), ‘before’ => strtotime( ‘previous week Friday’ ) ) ); $base = get_posts($base_array); I’ve not tested it. But I tested that below code returns the perfect … Read more

Get_Posts, only if in both categories

Use WP_Query‘s category__and: $args = array( ‘posts_per_page’ => 5, ‘category__and’ => array( 93, 85 ) ); $my_query = new WP_Query( $args ); while( $my_query->have_posts() ): $my_query->the_post(); the_title(); endwhile; wp_reset_postdata();

setup_postdata doesn`t seem ot be working

According to the Codex, you seem to skip the most important global $post; at the beginning, like this: global $post; $posts = get_posts($args); foreach($posts as $post) { setup_postdata($post); ?> <article class=”col two tablet-four mobile-six box”> <a href=”https://wordpress.stackexchange.com/questions/131909/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>”> <div class=”featured-image”> <?php if(has_post_thumbnail(get_the_ID())): ?> <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), array(650,200)); ?> <div style=”background: … Read more