Filter and Order by Multiple Custom Meta Values

For multiple meta value you have to use “IN” $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘shows’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘start_date’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘show_location’, ‘value’ => array(‘second’,’third’), ‘compare’ => ‘IN’ ) ) ); // get results $the_query = new WP_Query( $args ); The IN comparison … Read more

Stuck in the query loop

<div class=”pr_grid_cell clearfix”> <?php //for each category, show posts $categories=get_categories(); foreach($categories as $cat) { $args=array( ‘post_type’ => ‘products’, ‘showposts’ => -1, ‘category__in’ => array($cat->term_id) ); $posts = new wp_query($args); // This is the best way to if ($posts->have_posts()) while ($posts->have_posts()) { //condional if/while 2-in-1. If you dont check have_posts, you’ll get an ugly error when … Read more

Query posts by last comments

i thinks this help to you $args = array ( ‘status’ => ‘approve’, ‘number’ => ‘5’ ); $comments = get_comments( $args ); if ( !empty( $comments ) ) : echo ‘<ul>’; foreach( $comments as $comment ) : echo ‘<li><a href=”‘ . get_permalink( $comment->comment_post_ID ) . ‘#comment-‘ . $comment->comment_ID . ‘”>’ . $comment->comment_author . ‘ on … Read more

How to get all tags of a custom post type by id

Loop approach: usually archive-{custom_post}.php file. FIRST: custom_post_plural Stands for a group of custom posts of certain type. Example of custom_post_plural: products custom_post_singular Stands for an individual custom post type. Example of custom_post_singular: product SECOND: var $args_custom_post_plural are the parameters of the WP_Query. var $custom_post_plural is the execution of the query. I used var $custom_post_plural_output to … Read more