Storing query variable and then using wp_reset_query

wp_reset_query(); resets the query to the original main query of the page. Therefore, storing the query in another variable is redundant and unnecessary. Updated code: $args = array( ‘cat’ => 15, ‘paged’ => $paged ); $custom_query = new WP_Query( $args ); while ($custom_query -> have_posts()) : $custom_query -> the_post(); endwhile; my_pagination(); //call function wp_reset_query(); //#3. … Read more

Normal pages as children of my Custom Post Type

If it were me, here’s how I’d achieve this. Preface Assuming the following data structures: Post type: “dictionary” Taxonomy: “dictionary_category”, terms limited to single letters And the desired URLs: /dictionary/ => page (this should work out-of-the-box) /dictionary/rules/ => page /dictionary/x/ => Taxonomy archive /dictionary/x/xavier/ => Single post view 1. Set the post type and taxonomy … Read more

Display posts from multiple user roles

// Query user data on admins $administrators = new WP_User_Query( array( ‘role’ => ‘administrator’ ) ); // Query user data on contributors $contributors = new WP_User_Query( array( ‘role’ => ‘contributor’ ) ); // Save admin IDs foreach( $administrators->results as $u ) $user_ids[] = $u->ID; // Save contributor IDs foreach( $contributors->results as $u ) $user_ids[] = … Read more

Query custom post type in the loop

You are probably getting a rewrite conflict with the has_archive argument here: $args = array( ‘labels’ => $labels, ‘description’ => ‘Holds our services and service specific data’, ‘public’ => true, ‘menu_position’ => 5, ‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’ ), ‘has_archive’ => true, ); Set has_archive to false if you do not want the automatically … Read more

have_posts() execution failure

Your problem is the weird code at the top of the page. To understand what’s happening let me state a standard loop in pseudocode: if we still have posts to process while we still have posts to process mark this post as processed and move to the next one do things with it ( like … Read more

Random loop with code to prevent duplicate output returns no output at all from time to time

The problem is how you’re doing the exclusion. It’s happening after you’ve grabbed your second quote. If it matches the first quote, it just silently fails to appear. Try this for your 2nd block: <blockquote class=”container” style=”color:#1f8665;”> <?php $args = array( ‘post_type’ => ‘quotes’, ‘thesections’ => ‘yoga’, ‘posts_per_page’ => 1, ‘post__not_in’ => array( $do_not_duplicate ), … Read more