• Hi, So we added a custom field to our stores to add a date. We want to remove a badge that displays that its “fresh product” on our template after 30days goes by. I wrote the falling php code to do this, however I can’t seem to get it to work. I’m reaching out to all you smart php coders that could give me some pointers on what I’m doing wrong! Thanks for your help in advance!

    The code in functions.php:

    if(strtotime(date('m-d-Y')) > strtotime('+30 days', strtotime('<%= fresh_drop_date %>'))) {
    	$listing_template .= "\t\t\t" . '<p class="fresh-date" ><%= fresh_drop_date %></p>' . "\r\n";
    		
    	} else { 
    	$listing_template .= "\t\t\t" . '<% if ( fresh_drop_date ) { %>' . "\r\n";
        $listing_template .= "\t\t\t" . '<div class="fresh-img"></div>' . "\r\n";
    	$listing_template .= "\t\t\t" . '<p class="fresh-date"> <%= fresh_drop_date %> </p>' . "\r\n";
    	$listing_template .= "\t\t\t" . '<% } %>' . "\r\n";
    	
    	} 
    	

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hi there!

    Thanks for reaching out. Whenever you do any changes to the template in your functions.php file, it is generally a good idea to clear the Wp Store Locator transient cache. It is a button in the Store Locator settings, near the end.

    Also, although I guess you have already done it, please check the value of the <%= fresh_drop_date %> variable in the template. Print it outside the conditional statement and make sure it has a value.

    Get back to us if any of the above does the trick ??

    Regards!

Viewing 1 replies (of 1 total)
  • The topic ‘Adding If statements to templates’ is closed to new replies.