WordPress.org

Ready to get started?Download WordPress

Forums

Content Scheduler
If enabled show time left, if disabled don't (2 posts)

  1. Luke Etheridge
    Member
    Posted 1 year ago #

    Hi there,

    The title kind of says it all but I was just wondering if there was a way to display the 'time left' (as I call it) within the post ONLY if the content scheduler is enabled.

    At present it displays great for the posts with it enabled, but says '-15913 Days Left' for all those who have the content scheduler disabled.

    Here is my code, if you could tell me what to wrap it in I will be very grateful...

    <?php global $wp_query;
    		$postid = $wp_query->post->ID;
    
    		//Convert to date
    		$datestr=get_post_meta($postid, '_cs-expire-date', true);//Your date
    		$date=strtotime($datestr);//Converted to a PHP date (a second count)
    
    		//Calculate difference
    		$diff=$date-time();//time returns current time in seconds
    		$days=floor($diff/(60*60*24));//seconds/minute*minutes/hour*hours/day)
    
    		//Report
    		echo "$days Days Left";
    ?>

    Thanks,
    Luke

    http://wordpress.org/plugins/content-scheduler/

  2. Luke Etheridge
    Member
    Posted 1 year ago #

    Anyone have an answer for this??

    I'm pretty sure it's an easy fix...

    Thanks in advance.
    Luke

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic