• Hi,

    I have a category called “Shows” where I post programs which broadcast on different days/time. What I want is to DISPLAY the program from “Shows” category based on time/date.

    For example:
    I have created a post which broadcast on Every Monday at 6:00 PM, what I want is to show the post on Monday 6:00 PM for about an hour and hides automatically and show again on next week Monday 6:00 PM only. I have installed ACF date&time picker plugin also. Here is my query:

    <?php
    global $post;
    $args = array('category' => 8, 'numberposts' => 4,'orderby' => 'date','order' => 'ASC',);
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) : setup_postdata($post); ?>
    <?php
    $postDate = strtotime( $post->post_date );
    $todaysDate = time() - (time() % 86400);
    $todayTime = get_field('now_show_time');
    $time= time();
    if ( $postDate >= $todayTime) : ?>
    <li><a href="<?php the_permalink(); ?>" style="font-size:11px;"><span style="font-weight:bold;color:#afaca5"><?php the_time('n/j'); ?>:</span> <?php the_title_attribute(); ?></a></li>
    <?php endif; ?>
    <?php endforeach; ?>

    Please help me to find a solution and tell me what am I doing wrong there?

  • The topic ‘Show/Hide post based on time’ is closed to new replies.