Minimising number of queries on a page when using Advanced Custom Fields

Performance optimization doesn’t really work in vaccum, it takes hands-on profiling an looking for actual bottle necks (which often turn out to be different from perceived ones). But it general there are several approaches to the need of lots of database data: Optimize fetching from database, for example by concatenating multiple requests into retrieving single … Read more

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