Listing custom post type items from a couple of custom taxonomies
Listing custom post type items from a couple of custom taxonomies
Listing custom post type items from a couple of custom taxonomies
While using query_post(), you can reset the query at the end by using <?php query_posts(‘post_type=ill-portfolio&posts_per_page=3’); . . . <?php endwhile; endif;?> <?php // Reset Query wp_reset_query(); ?>
In order to get pagination working with secondary Loops, you have to pass the $paged parameter to WP_Query, other wise the query does not know which set of posts to load and will load the first set, page 1, every time. I got it to work by adding ‘paged’ => $paged inside the $args = … Read more
In case anyone runs into trouble like I did, I figured it out! $taxonomy_1 = get_terms( ‘taxonomy_1’, $args_1 ); $taxonomy_2 = get_terms( ‘taxonomy_2’, $args_2 ); foreach( $taxonomy_1 as $tax_1 ) { foreach( $taxonomy_2 as $tax_2 ) { $posts = get_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘ENTER-YOUR-CPT’, ‘order’ => ‘ASC’, ‘orderby’ => ‘title’, ‘taxonomy’ => … Read more
Try using $wp_query global variable: global $wp_query; $postid = $wp_query->post->ID;
in your code, you are checking the category of a post which is quite random outside of the loop and when the posts have more than one category; the category ID of a category archive page is usually: $cat_ID = get_query_var(‘cat’);
I found that I was able to do this by using the Instagrate Pro plugin, which creates individual posts for every image it pulls in from Instagram. The standard loop then just pulls in those posts into the archive.
I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more
have_posts() iterates over all posts found and actually returned in the query which depend in the posts_per_page parameter. And for your second question, using query_posts() does overwrite the query and its not really the recommend method to alter or modify the query result, here is a nice question that explains better ways : When should … Read more
I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more