Ready to get started?Download WordPress


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

  1. Luke Etheridge
    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
    		echo "$days Days Left";



  2. Luke Etheridge
    Posted 1 year ago #

    Anyone have an answer for this??

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

    Thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic