get all categories’ latest post in one query

Quantity of queries isn’t the only measure of performance, an individual query can cost more than numerous simple queries. The cost of (small query) x12 < cost of large query x1 + string/array manipulation You would be better doing the 12 individual queries. If it is costly, store the result in a transient for a … Read more

How can I exclude a category from the main loop with the category name & not ID?

You directly cannot pass the name or slug for excluding a particular category. You have to use the id. Modifying your code: <?php $category_id = get_cat_ID(‘featured’); //if get_query_var(‘paged’) doesn’t work, then try using get_query_var(‘page’) in the next line. $paged = (get_query_var(‘paged’))?get_query_var(‘paged’):1; $q = array(); $q[‘category__not_in’] = array($category_id); $q[‘paged’] = $paged; query_posts($q); if (have_posts()) : while … Read more

Sort posts alphabetically by category/custom taxonomy, insert divider between different types

after some trials I’ve got one solution that seems to be good but I need some tweaking help <ul class=”list-ensemble”> <?php $terms = get_terms(“production_co_type”); $count = count($terms); if ( $count > 0 ){ echo “<ul>”; foreach ( $terms as $term ) { echo ‘<li class=”title”>’ . $term->name . ‘</li>’; $args = array ( ‘post-type’=> ‘shows’, … Read more

Category sticky latest

What you’re looking for is best achieved using a custom query: $top = new WP_Query( array( ‘category’ => ‘YOUR_CATEGORY_SLUG’, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 1 ) ); if( $top->have_posts() ) { $top->the_post(); // Do things as if we were in the loop… } By default, sticky posts are brought to the top … Read more