Exclude post ID from wp_query

How can I exclude one specific post from a WP_Query query? (For example, show all posts apart from a post with the ID 278) I’ve tried the post__not_in argument but it just removes all posts.. Any help would be great. Here is my current query <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(array( … Read more

Pagination when using wp_query?

<!– query –> <?php $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $query = new WP_Query( array( ‘category_name’ => ‘investor-news’, ‘posts_per_page’ => 2, ‘paged’ => $paged ) ); ?> <?php if ( $query->have_posts() ) : ?> <!– begin loop –> <?php while ( $query->have_posts() ) : $query->the_post(); ?> <h2><a href=”https://wordpress.stackexchange.com/questions/254199/<?php … Read more

Get post ids from WP_Query?

Is there a way I can retrieve an array of post ids queried from the following: $latest = new WP_Query( array ( ‘orderby’ => ‘rand’, ‘posts_per_page’ => 3 )); if ( $latest -> have_posts() ) : while ( $latest -> have_posts() ) : $latest -> the_post(); get_template_part( ‘templates/content’, ‘post’ ); endwhile; endif; wp_reset_postdata(); Follow Up: … Read more

WP_Query with “post_title LIKE ‘something%'”?

I need to do a WP_Query with a LIKE on the post_title. I started with this regular WP_Query: $wp_query = new WP_Query( array ( ‘post_type’ => ‘wp_exposants’, ‘posts_per_page’ => ‘1’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘paged’ => $paged ) ); But what I actually want to do looks like this in … Read more