WordPress, custom post type and posts query help!

You are doing so many things wrong there, for example, you should only use query_posts once in a template file and on the main query of the page, anything else should be done using get_posts or WP_Query. So to make you post types mingle you only need on query and you set the post type … Read more

Trying to exclude custom posts based on date, while sorting by custom field

You need to make use of meta_query http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters <?php $paged = ( get_query_var(‘paged’) ) ? get_query_var(‘paged’) : 1; query_posts(array( ‘post_type’ => ‘performance’, ‘posts_per_page’ => 5, ‘caller_get_posts’ => 5, ‘paged’ => $paged, ‘meta_key’ => ‘order-date’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘order-date’, ‘value’ => $value, ‘compare’ => ‘>=’, ‘type’ => … Read more

Show 10 latest posts only from users with contributors role

you can use the author parameter of WP_Query here is a simple function to get you going with a hook to a shortcode and another hook to render this shortcode inside a simple text widget: function ten_latest_of_contributers($atts = null){ global $post; //store the current post data $temp = $post; $contributors = get_users(array(‘role’=> ‘contributor’)); //then create … Read more

Query pulling a single post per month

Maybe a bit less hacky: $months = array(); while(….){ list($month, $year) = explode(“https://wordpress.stackexchange.com/”, get_the_date(‘n/y’)); // eg. 7/11 if(in_array($month, $months)) continue; // skip $months[] = $month; echo ‘<li><a href=”‘.get_month_link($month, $year).'”>’.get_the_date(‘F Y’).'</a></li>’; } If you’re only getting 6 posts and you don’t need pagination that I guess it’s OK to go this way. Otherwise you need to … Read more

Formatting a date/time returned from a custom $wpdb query

A much simpler method to bypass these issues is using WP_Query: $popularQuery = array(‘orderby’ => ‘comment_count’, ‘posts_per_page’ => ‘-1’, ‘author’ => 1); $popularPosts = new WP_Query($popularQuery); while($popularPosts->have_posts()) : $popularPosts->the_post(); ?> <tr> <td><a href=”https://wordpress.stackexchange.com/questions/23820/<?php the_permalink(); ?>”><?php the_title(); ?></a></td> <td><?php the_author(); ?></td> <td><?php the_time(‘j M Y h:i A’) ?></td> <td><?php comments_number(); ?></td> </tr> <?php endwhile; Also note … Read more

Get current taxonomy and display query accordingly

I think you’re on the right path with splitting some of your categories out to separate taxonomies. Have a look at the Query Multiple Taxonomies plugin that will give visitors a widget interface for filtering posts: Query Multiple Taxonomies Widget http://s.wordpress.org/extend/plugins/query-multiple-taxonomies/screenshot-1.png

Custom query Custom-Post-Types creates error

just use query_posts(‘post_type=team-member&posts_per_page=2&paged=$paged’); instead of $wp_query = new WP_Query( array( ‘post_type’ => ‘team-member’, ‘posts_per_page’ => 2, ‘paged’=>$paged ) ); and then the while loop as if(have_posts()) while(have_posts()) : the_post(); instead of <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>