Display a post for a specific time !
-
Hello all
i want to display one post from a category for a specific time
e.g. for 1 week or 1 monthon search i found this useful code
<?php // initialize new query of one post from category 11 $my_query = new WP_Query('cat=11&showposts=1'); // loop through the database to find related information while ($my_query->have_posts()) : $my_query->the_post(); // set expiration time of two days $goAwayDate = time() - (60 * 60 * 24 * 2); // get date of sticky post $postDate = get_the_time('U'); // if post is too old, do nothing if ($postDate < $goAwayDate) { // else show the post } else { ?> <h1><?php the_title(); ?></h1> <?php the_excerpt(); ?> <?php } endwhile; ?>——————————-
I want to select 2-3 posts from a certain category
& then set show & expire time for each post i.e. 1 week or 1 month
& then using if else statement show the post as per the time period
& for else part (if all expired period expired) use the latest from that selected category 🙂thanx in advance
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Display a post for a specific time !’ is closed to new replies.