excluding posts via custom field
-
Basically I’m taking posts and sorting them by custome field ‘date’ and then displaying them, I am doing so in a widget using the first bit of code and it works great, the second bit of code is meant for archive.php and it works in sorting the posts but I don’t want to display the posts once it has been passed todaysdate
First bit of code
<?php // Get today's date in the right format $todaysDate = date('d/m/y H:i:s'); ?> ? <?php query_posts('showposts=5&category_name=Events - NSW&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC'); ?> <ul> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <li> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <p><?php the_excerpt(); ?></p> </li> <?php endwhile; else: ?> <li>Sorry, no upcoming events!</li> <?php endif; ?> </ul> <?php wp_reset_query(); ?>
I’m trying to do the same in archive.php to sort the posts in the category page in the same manner, so I am using this and it works
<?php if( is_category('5') ) { //$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args= array( 'meta_value' => $todaysDate, 'meta_key' => 'date', 'orderby' => 'date', 'order' => 'ASC', 'cat' => 5, 'paged' => $paged ); query_posts($args);} ?>
As I said near the top of the post, I want to add something to this code in archive.php to exclude the posts that have passed todaysdate
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘excluding posts via custom field’ is closed to new replies.