Can I create a loop with multiple post types and specify different $args for each post type?

Can I create a loop with multiple post types and specify different $args for each post type? Simply put no… you can’t have a single query instance with three differing sets of arguments. The reason why is pretty simple, the query class will only take one array of arguments per instance. If you want differing … Read more

Breaking the loop?

I don’t think i’ve fully grasped how you want this to work, but if i assume for a moment that as long as the loop has at least 6 posts, you want to insert extra markup after the third result in the loop.. Example Insert extra markup after the third post, when the current iteration … Read more

get_template_part and template file names

Codex has very decent explanation of get_template_part() logic: Assuming the theme folder is wp-content/themes, that the parent theme is twentyten, and the child theme is twentytenchild, then the following code — <?php get_template_part( ‘loop’, ‘index’ ); ?> will do a PHP require() for the named files in this order: wp-content/themes/twentytenchild/loop-index.php wp-content/themes/twentytenchild/loop.php wp-content/themes/twentyten/loop-index.php wp-content/themes/twentyten/loop.php Basically you … Read more

query_posts() ALWAYS displays something?

query_posts() ALWAYS displays something? No it doesn’t at least not for me, i’ve tried the code you posted inside my child theme and was unable to reproduce the issue described. Firstly, i tried… while ( have_posts() ) : the_post(); ?> <!— DO NOTHING ! –> <?php endwhile ?> ..and got nothing, so i then tested.. … Read more

Sub-loop / nested loops Best Practices

First see When should you use WP_Query vs query_posts() vs get_posts()? My understanding of “The Loop” is that there is, and should only ever be, ONE “The Loop” per page/post – and that The Loop is responsible for iterating through that page/post/archive’s content. Yes, it’s commonly referred to as “main loop”. But “loop” in general … Read more

Filtering post-formats from the loop using new WP-Query();

You should be able to exclude posts with a specific format using WP_Query’s tax_query parameter. Eg. $q_args = array( ‘posts_per_page’ => 1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array( ‘post-format-link’ ), ‘operator’ => ‘NOT IN’ ) ) ); $featured->query( $q_args ); Untested, but should do the trick..

Help with WordPress Query

After calling get_recent_posts() (or any other loop query), you typically have to run a foreach or while loop to cycle through the posts. So, you’ll need to change this: <?php $args = array( ‘tag’ => ‘featured’, ‘posts_per_page’ => ‘3’ ); $recent_posts = wp_get_recent_posts( $args ); ?> <!– Your HTML and WordPress template tags here. –> … Read more

I’ve been out of the loop since 2.8. What did I miss?

In no particular order, other notable things are: old default theme was deprecated in favor of annual theme changes, you jumped over Twenty Ten theme and current one is Twenty Eleven WordPress MU was merged into mainline WordPress and is now called multisite feature serious improvements to complex querying by taxonomies and custom fields server … Read more

Change or update WordPress loop based on dropdown selection

First use this code for populating parent dropdown. <select id=”parent”> <option>-</option> <?php if(taxonomy_exists(‘parent_taxonomy_name’)): $results = get_terms(‘parent_taxonomy_name’,array(‘fields’=>’all’,’parent’=>0)); if ($results): foreach ($results as $result): ?> <option value=”<?php echo $result->name; ?>”><?php echo $result->name; ?></option> <?php endforeach; endif; endif; ?> </select> You may need to use ajax/jquery to fill in the 2nd dropdown box. <select id=”child”> <option>-</option> </select> jquery … Read more