Tag Info

Hot answers tagged

2

You cannot use the same object of WP_Query twice. Therefore you need to create another one with a tax_query parameter to fetch posts which are not assigned to any term. //fetch all reviews which have no assigned term in 'review-product' $taxonomy = 'review-product'; $post_type = 'reviews'; $args = array( 'post_type' => $post_type, 'tax_query' ...


2

The title of question is inaccurate. I think you don't want to escape first post, instead you want to exclude current post. You can use the post__not_in argument in WP_Query. $args = array( 's' => 'searchTerm' ); //Check if we are in a post of any type if( is_singular() ) { $post = get_queried_object(); $args['post__not_in'] = array( ...


1

Use pre_get_posts instead.. function my_archive_query_override( $query ) { if ( $query->is_archive() && $query->is_main_query() ) { $query->set( 'orderby', 'rand' ); } } add_action( 'pre_get_posts', 'my_archive_query_override' ); For that user selectable part, you can use AJAX to accomplish that.


1

I think you forgot to check if $the_query have posts. <?php $args = array( 'post_type' => 'testimonials', 'posts_per_page' => 1, 'orderby' => 'rand' ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ...



Only top voted, non community-wiki answers of a minimum length are eligible