Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i have a "featured" section on home page. i want to hide this section after 10 minutes of post publish time. here is the code, i am using. problem is that it hide the "featured" section after 12 hours of post publish time

------- index.php -------

<?php $args = array(
    'posts_per_page' => 1, // We are showing only one post
    'category_name' => 'featured_post' // showing form category prime
                        );

add_filter( 'posts_where', 'filter_where' );
$the_query = new WP_Query( $args );
remove_filter( 'posts_where', 'filter_where' ); ?>

<?php
if ($the_query->have_posts()) :?>
 <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php endwhile; ?>
<div class="featured_post">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
<?php endif; ?>

------- Function.php -------

 function filter_where( $where = '' ) {
 // posts published last 30 minutes
 $where .= " AND post_date > '" . date('Y-m-d H:i:s', strtotime('-10 minutes')) . "'";
 return $where;
 }

please guide me.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.