show only posts after current date in wp_query (3 posts)

  1. nickbrewer
    Posted 5 years ago #

    hi all!

    i'm trying to alter the below wp_query to only show posts after the current date/time.

    right now i have the plugin installed that makes all 'future' [scheduled] posts mark as 'publish'. My goal is to list all posts beyond the current date and not list the past posts.

    some of the below code is from a custom theme so the .$catid. variable is custom.

    as of now the query works it just shows all the posts [past and future]. i'm guessing there is some variable i need to compare to the current date. not sure what to do.

    $my_query = new WP_Query("cat=".$catid."&posts_per_page=1&orderby=date&post_status=publish");
                while ($my_query->have_posts()) : $my_query->the_post();

    thanks in advance for the help!

  2. MichaelH
    Posted 5 years ago #

    You need to use the template tag, query_posts(), and look at the examples of Time Parameters and use the 30 day example but use 0 for the days.

  3. djameskennedy
    Posted 5 years ago #

    Nick, I just went through the same thing. First of all, disable the plugin that gets rid of the post_status=future.

    and install this plugin if you want to be able to view the single future posts (without being logged in as admin):

    Show Future Posts on Single Post Plugin

    Try this, it just worked for me, unless of course you enjoy reading the wordpress codex.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.