Query all posts in a given taxonomy

Have you tried simply omitting the ‘terms’ key from the ‘tax_query’ array? $query03 = array( ‘numberposts’ => 5, ‘post_type’ => array( ‘video’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product’, ‘field’ => ‘slug’ ) ) ); Alternately, I wouldn’t really worry about the weight of the query. The resulting query will be what it will … Read more

Retreaving all images attached to current post

From get_media_items function and his code, you can use get_children adding mime type for images: $images = get_children( array( ‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order ASC, ID’, ‘order’ => ‘DESC’) ); That will get you an array ($images) of images attached to $post_id. In you case, if you’re inside … Read more

Pagination problem after WP_Query with tag filtering

Finally I’ve figured out the correct coding for this problem: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $wp_query = new WP_Query(); $wp_query->query(‘tag=concurs&posts_per_page=”.get_option(“posts_per_page’).’&paged=’ . $paged); ?> <?php if ($wp_query->have_posts()) : ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> [code for title, author, category, meta-info etc] <?php endwhile; ?> <div class=”next-prev”><?php posts_nav_link( ‘ ‘, ‘<img … Read more

Arrange BBpress topics by created

Add this to a plugin or your active themes functions.php function my_custom_display_topic_index_query () { $args[‘orderby’] = ‘date’; $args[‘order’] = ‘DESC’; return $args; } add_filter(‘bbp_before_has_topics_parse_args’, ‘my_custom_display_topic_index_query’ );

Custom Post order for homepage

From a naming standpoint it seems that the term “filter” would be more appropriate since you are filtering by criteria first and then a sort (directional) is applied when you order. But that’s more a naming convention standpoint… From a code structure if you are using the check_for_popular() method in several places then it makes … Read more