Displaying posts limit: can’t get pagination to display [duplicate]

Try reviewing this page on the codex. Using your above template, I would suggest the following: <?php if ( is_user_logged_in() ) : $args = array( ‘posts_per_page’ => ‘5’, ‘author’ => get_current_user_id(), // Removes a few lines of code 😉 ); $author_posts = new WP_Query( $args ); ?> <?php /* Author has posts? */ ?> <?php … Read more

the loop – how to control whether wp or plug-in runs it

The problem was in my the loop.php file, i was executing a new loop using the wordpress parameters for the main loop, which caused a duplication with the plugin being used (thecartpress) which executes its own loop. I was using: global $post, $query_string, $discTheme; query_posts($query_string); in a sense, with thecartpresses own loop, I was duplicating … Read more

$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

loop through custom post-type with two meta_keys

You’ll need to use meta_query along with meta_(key|value|compare) to interact with two different keys and get the order you want. <?php $q = new WP_Query(array( ‘post_type’ => ‘my_project’, ‘nopaging’ => true, // same as posts_per_page => 1, ‘order’ => $order, ‘orderby’ => ‘is_featured_position’, // your position key here ‘meta_key’ => ‘is_featured_position’, // also here, see … Read more