Add countdown timer for each scheduled post

Question

I have here code that shows all of the data in my CPT, all of the data here are scheduled post, Is it possible to show the countdown timer of the each post until the date posted?

        $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    $args = array(
        'post_type' =>array('complan_a','complan_b','complan_c'),
        'posts_per_page' => -1,
        'orderby' => 'menu_order',
        'order' => 'ASC',
        'post_status' => array('publish','future'),
        'paged' => $paged,
        'title' =>  $username
       
   
    );
    $the_query = new WP_Query( $args );
    

if ( $the_query->have_posts() ) :
    while ( $the_query->have_posts() ) : $the_query->the_post();

        $payin_id   = get_the_ID();
        $complan_a = get_field('complan_amount',$post_id);
        $complan_b = get_field('complan_b_amount', $payin_id);
        $complan_c = get_field('complan_c_amount',$post_id);
                                 ?>

 <tr>

    <td><?php echo $complan_a;?>
    <?php echo $complan_b;?>
    <?php echo $complan_c;?></td>
    <td></td>                                                                                 
                                            
</tr>

    
<?php
endwhile;
wp_reset_postdata();
endif;
?>

I found this code to show each remaining days of each post, but the problem is its only shows the remaining day not the hours, minutes and seconds

 function bc_timer_func( $atts ) {
$a = shortcode_atts( array(
    'days' => '0',
), $atts );
$days = $a['days'] - ( time() - get_post_datetime()->getTimestamp()) / DAY_IN_SECONDS;
$days = 0 > $days ? 0 : (int) $days;
return $days;
}

I think this need to use Jquery function, but I dont know where to start. Please help. thanks

0
Eunice 4 days 2022-11-24T02:04:26-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse