Support » Fixing WordPress » How to hide after 1 hours.

  • hi i am using these code to hide #prime_news after 1 hours from post date
    but it working after 12 hours.
    what should i do to hide this section #prime_news after 30 minutes or 1 hours from post date ?

    <?php $args = array(
                                'posts_per_page' => 1, // We are showing only one post
                                'category_name' => 'prime' // showing form category prime
                                );
    
    // Create a new filtering function that will add our where clause to the query
    function filter_where( $where = '' ) {
        // posts published last 5 hours
        $where .= " AND post_date > '" . date('Y-m-d', strtotime('-1 hours')) . "'";
        return $where;
    }
    
    add_filter( 'posts_where', 'filter_where' );
    $the_query = new WP_Query( $args );
    remove_filter( 'posts_where', 'filter_where' ); ?>
    
     <div id="prime_news" class="col-full">
     <?php
        if ($the_query->have_posts()) :?>
    <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
    <?php endwhile; ?>
    <div class="prime_left fl">
    <h3><a href="<?php the_permalink(); ?>" title="" class="title_slide"><?php the_title(); ?></a></h3> </div>
    </div>
        <?php endif; ?>
  • The topic ‘How to hide after 1 hours.’ is closed to new replies.