SteveEn_E Posted August 4, 2009 Share Posted August 4, 2009 Hello, been trying to figure out how I can add some php-code into my sidebar of wordpress so that it automatically shows a different picture based on the date. I'm going to do a roadtrip and would like to show the map of what we are doing that day so I figured based on some guidelines from a friend I would try this: <li> <h2>Wat doen we vandaag?</h2> <ul> <?php $vandaag = mktime(0,0,0,date("m"),date("d"),date("Y")); $waar=(d-m-Y); Switch ($waar) case="04-08-2009": <img src="http://temp.com/wp-content/6Aug.jpg" alt="Los Angeles">; ?> </ul> </li> But it aint really showing something, actually the whole sidebar disappears when I add that little line of code... Quote Link to comment Share on other sites More sharing options...
Garethp Posted August 4, 2009 Share Posted August 4, 2009 Switch ($waar) case="04-08-2009": <img src="http://temp.com/wp-content/6Aug.jpg" alt="Los Angeles">; Should be Switch ($waar) { case="04-08-2009": echo "<img src=\"http://temp.com/wp-content/6Aug.jpg\" alt=\"Los Angeles\">; break; } However, this does not belong in the Regex forum Quote Link to comment Share on other sites More sharing options...
Adam Posted August 4, 2009 Share Posted August 4, 2009 The syntax is completely wrong. Should be: $waar = ("d-m-Y"); switch ($waar) { case "04-08-2009": echo '<img src="http://temp.com/wp-content/6Aug.jpg" alt="Los Angeles">'; break; case "05-08-2009": // ... break; } Quote Link to comment Share on other sites More sharing options...
SteveEn_E Posted August 4, 2009 Author Share Posted August 4, 2009 Thxs for the help, sorry for the wrong section... I'm currently testing this, and it is working with text but not with images (like I want to use them). Any idea what the reason could be? Also, it seems to not be possible to show the image/text of the selected date. I added the default line and its always showing this. Might there something wrong in the mktime? Quote Link to comment Share on other sites More sharing options...
Adam Posted August 4, 2009 Share Posted August 4, 2009 Oh dear, silly oversight. Should be: $waar = date("d-m-Y"); Quote Link to comment Share on other sites More sharing options...
SteveEn_E Posted August 4, 2009 Author Share Posted August 4, 2009 Cool, That worked. While I was waiting for a reply I kinda already figured out my mistake was at the $waar :-) The fact it doesnt want to show images might be cause of my css? Quote Link to comment Share on other sites More sharing options...
Adam Posted August 4, 2009 Share Posted August 4, 2009 How do you mean it doesn't want to show them? What is shown, or, what happens? Quote Link to comment Share on other sites More sharing options...
SteveEn_E Posted August 4, 2009 Author Share Posted August 4, 2009 I sent you a PM, thxs for helping. 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.