Pagination not working on homepage

This is my working pagination query. I’ve updated it to use the parameters in your question: <?php if ( get_query_var(‘paged’) ) { $paged = get_query_var(‘paged’); } else if ( get_query_var(‘page’) ) { $paged = get_query_var(‘page’); } else { $paged = 1; } $args = array( ‘post_type’ => array(‘post’, ‘music’, ‘videos’), ‘post_status’ => ‘publish’, ‘posts_per_page’ => … Read more

wp query problem

While comparing numbers in meta value use “meta_value_num” instead of “meta_value” ‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’. Reference

$query conflicting with other queries in the same page

function pre_get_posts( $query ){ if(isset($query->getpostlist) && $query->getpostlist) { add_filter( ‘posts_fields’, ‘postsetupFields’, 20); } else { remove_filter( ‘posts_fields’, ‘postsetupFields’, 20); } return $query; } function postsetupFields( $fields ){ global $wpdb; $fields = “{$wpdb->posts}.ID”; return $fields; } add_action( ‘pre_get_posts’, ‘postsetupFields’);

Display posts where date field matches current month?

You can use the meta_query parameter to display all events for the current month like this: $start_date = date( ‘ym01’ ); $end_date = date( ‘ymt’ ); $meta_query = array( ‘key’ => ‘event_date’, ‘value’ => array( $start_date, $end_date ), ‘compare’ => ‘BETWEEN’, ‘type’ => ‘NUMERIC’ ); $args = array( ‘post_type’ => ‘hh_event’, ‘posts_per_page’ => -1, ‘orderby’ … Read more

Multiple loop for “featured” items returns wrong posts

Your second loop is fine because it works – although it is probably more efficient to do it this way: $args = array( ‘post_type’ => ‘onourradar’, ‘posts_per_page’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘offset’ => ‘2’); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); The difference is that a do_not_duplicate query is just … Read more

WP_Query based on a custom field result

Here’s the corrected code, thanks @Milo! <ul> <?php $recentPosts = new WP_Query(); $recentPosts->query(‘showposts=6&cat=1&meta_key=ticker&meta_value=yes’); ?> <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <li> <?php if ( has_post_thumbnail() ) {?> <div class=”post-thumb-140″> <a href=”https://wordpress.stackexchange.com/questions/78477/<?php the_permalink() ?>”><?php the_post_thumbnail( ‘post-thumb-140’ ); ?></a> </div> <!–post-thumb–> <?php } ?> <a href=”https://wordpress.stackexchange.com/questions/78477/<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a> </li> <?php endwhile; ?> </ul>