Forums

ONLY show future (and today) posts (5 posts)

  1. puffin
    Member
    Posted 2 years ago #

    I'm trying to show only future posts for a particular (gigs) category.

    I managed to get it showing future posts, but now it won't delete past ones. This is what I have at the moment:

    <?php query_posts('category_name=gigs&posts_per_page=100&post_status=future&order=ASC'); ?>
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    What do I need to change in order for past events to drop off?
    I'd like it still to show an event on the same day.

  2. David Calhoun
    Member
    Posted 2 years ago #

    Check out the time parameters for query_posts. You might could do something like:

    function filter_where( $where = '' ) {
    	// posts in the next 30 days
    	$where .= " AND post_date > '" . date('Y-m-d', strtotime('+30 days')) . "'";
    	return $where;
    }
    add_filter( 'posts_where', 'filter_where' );
    
    $query = new WP_Query( $query_string );
  3. puffin
    Member
    Posted 2 years ago #

    David, thank you so much for helping - I'm embarrassed to confess I have absolutely no idea what to do with that code though. I don't understand PHP which is why wordpress is a nightmare for me!
    Where do I put a function in a PHP page?

  4. kreativjustin
    Member
    Posted 2 years ago #

    You'll have to integrate that code into the code your using to pull up your 'future' posts/gigs.

  5. puffin
    Member
    Posted 2 years ago #

    I know. I just don't know HOW to integrate it.

Topic Closed

This topic has been closed to new replies.

About this Topic