jdurden Posted October 12, 2011 Share Posted October 12, 2011 This should be simple but I cant figure it out. Basically, I just need to only display titles that have thumbnails, and it should always show titles with dates from the next two months. Therefore, since it is October, it should show the October and November titles, if it's November, it shows Nov and Dec, etc. The part of the code i need help with is at the bottom. [syntax=php]<?php $width = 940; $height = 277; $classtext = ''; $titletext = get_the_title(); $date = print(Date("l F d, Y")); $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false); $thumb = $thumbnail["thumb"]; ?> <?php // if there's a thumbnail if($thumb != '' && $date == ? ) { ?>[/syntax] Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 12, 2011 Share Posted October 12, 2011 Well, what format is the date returned from your function get_thumbnail()? Is it s UNIX timestamp a string format (if so, what format is it YYYY-MM-DD, MM-DD-YYYY, MonthName DD, YYYY, or what)? Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 12, 2011 Share Posted October 12, 2011 OK, looking at your code a little closer I see there is no date returned only $thumbnail["thumb"], which I assume to be the path to the thumbnail. In that case you could define variables for this month and next month, then get the value for the file using filemtime() and do your comparison. Also, you say you are doing this for multiple thumbnail images. So, you must be running some of this code in a loop - which you didn't provide. Just make sure you put anything outside the loop that doesn't need to be in the loop. For example all the variable assignments I would assume should be outside the loop. ### Outside the loop ### $width = 940; $height = 277; $classtext = ''; $titletext = get_the_title(); $date = print(Date("l F d, Y")); //Defne this and next month $thisMonth = date('Y-m'); $nextMonth = date('Y-m', strtotime('next month', strtotime("($thisMonth)-1"))); ### Inside the loop ### $thumbnail = get_thumbnail($width, $height, $classtext, $titletext, $titletext, false); $thumb = $thumbnail["thumb"]; //Get Year-Month of the thumbnail file $thumbMonth = date('Y-m', filemtime($thumbnail["thumb"])); if($thumb != '' && ($thumbMonth == $thisMonth || $thumbMonth == $nextMonth) ) { Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.