• I’m trying to run a WP_Query to retrieve posts containing a custom field called ‘event-date’ and only list the past events.

    The event date is stored in the YYYY-MM-DD format. So I want to list any posts that are smaller than $todaysdate (a variable in the same format).
    This is the WP_Query I’m using:

    $wp_query->query('posts_per_page=12&meta_key=event-date&meta_compare=<&meta_value='.$todays_date.'&orderby=meta_value&order=DESC&paged='.$paged);

    This works perfectly to retrieve only the posts I need, but pagination is very odd. For some reason it shows a link to ‘previous entries’ which doesn’t return any more details. So page 3 is blank.

    My guess is that the query is counting posts that don’t include the custom field.

    Does anyone know if my query REALLY is doing what I want it to?

  • The topic ‘Pagination showing blank pages for WP_Query retrieving custom fields’ is closed to new replies.