Jump to content

[SOLVED] Show picture based on the date


SteveEn_E

Recommended Posts

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...

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.