WP_Query and help with the loop for magazine front page

There is no reason to need 2 loops or to alter the query in any way if your are just showing the 9 most recent posts. You can use a loop counter to create the extra divs you need. <div id=”featured”> <?php $count = 0; if (have_posts()) : while (have_posts()) : the_post(); $count++; if ( … Read more

Custom Post Type Query W/Category Dropdown

You seem to be using 2 separate queries there, the first (query_posts) won’t do anything, and the second is the query that will be used. Have you tried: $args=array( ‘category__in’ => $cats, ‘post_type’ => ‘profiles’, ‘posts_per_page’ => 10, ‘order’=> ‘ASC’, ‘orderby’ => ‘title’ ); $loop= null; $loop = new WP_Query($args); Try that instead of: query_posts(array( … Read more

Magazine style frontpage with multiple categories/loops and no duplicate posts

I wrote a class specifically for passing data between widgets classes using static variables and it will work for your use case as well. Grab the class here. The way you would use this is as follows for each custom loop: $exclude_ids = IntermediaryData::get(); //Retrieve previous exclude IDs $args[‘post__not_in’] = $exclude_ids; //new WP_Query($args); Custom loop … Read more

How to get pages of parent (non-recursive)?

Assuming that, by “HOME_ID”, you are referring to the static Page used to display the Site Front Page, then you want to use get_option( ‘front_page’ ) to get the ID for this page: <?php $menu_wp_query_args = array( ‘post_type’ => ‘page’, ‘post_parent’ => get_option( ‘front_page’ ), ‘orderby’ => ‘menu_order’ ); $new_wp_query = new WP_Query( $new_wp_query_args ); … Read more

What’s wrong with this wpdb query?

Try this, it worked for me: global $wpdb; $terms = $wpdb->get_col( $wpdb->prepare( “SELECT name FROM {$wpdb->terms} WHERE term_group = %d ORDER BY name ASC”, primary_tag_id )); What you are after is $wpdb->terms not $wpdb->wp_terms

Help with Wp Query

$authors = get_users( array( ‘fields’ => ‘ID’, ‘role’ => ‘your_role’ )); $my_query = new WP_Query( array( ‘post_type’ => ‘your_post_type’, ‘author’ => implode( ‘,’, $authors ) ));

Modify output of custom loop using WP_query

$args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘hotwives’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => ‘slider’, ‘operator’ => ‘NOT IN’ ) ) ); Use that as the args for your WP_Query and you should get posts that aren’t in the category taxonomy. It also has the … Read more

Using WP_Query with multiple loops on one page in search.php

Alright, I just whipped something up, this should do it, but it’s untested. <?php $premium_args = array( ‘post_status’ => ‘publish’, ‘meta_query’ => array( array( ‘key’ => ‘seek_premium’, ‘value’ => ‘yes’ ) ) ); $premium_posts = new WP_Query( $premium_args ); ?> <?php foreach( $premium_posts as $p ) : ?> Your output here <?php endforeach; ?> <?php … Read more