SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Addict BlazeMiskulin's Avatar
    Join Date
    May 2007
    Location
    Wisconsin
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rotate Logos in WordPress?

    I'm going to be converting a static site over to WP in the near future, and there's a feature I'd like to automate, if possible.

    I've been creating "holiday logos" for the site (adding a bow for Christmas, a hard hat for Labor Day, etc.,) I'm wondering if anyone has run across a plug-in that would swap out the image files automatically.
    M Blaze Miskulin
    President
    Geek Niche Web Hosting

  2. #2
    _ silver trophy ses5909's Avatar
    Join Date
    Jul 2003
    Location
    NoVa
    Posts
    5,467
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Swap them out based on a set-date?
    Sara

  3. #3
    SitePoint Addict BlazeMiskulin's Avatar
    Join Date
    May 2007
    Location
    Wisconsin
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes.

    So on Dec 25, the Christmas logo shows up instead of the regular one, and then becomes the Boxing Day logo the next day, then reverts back to the regular one.

    I've been doing this by hand, but it's not exactly the most efficient way, and I often forget that it's a holiday.
    M Blaze Miskulin
    President
    Geek Niche Web Hosting

  4. #4
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's really no need for a plugin for this. Just put the function into the header.php file that swaps the images based on what day it is (this will be set server-side, just so you know).

    I have a dentist's appointment in a couple of hours, otherwise I'd see if I could whip one up for you (and I admit I'm not even good at PHP yet).

  5. #5
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do a search for something like 'php image event rotator' or something like that. There's bound to be a simple script out there for doing this. Or wait till Dan Schulz get's back. My php skills aren't up to creating something on the fly like Dan yet, I still need to do some Googling first :P

  6. #6
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not that good yet either, Ryan. I was going to consult my PHP book (which is at home - I'm at my brother's place right now).

  7. #7
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am going to watchout for this new freebie

  8. #8
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This will do it. Just change the date to whenever you want and it will pass whatever is in the echo ' .... ' statement as html.

    Code:
    <?php
    	$test=date("d m");
    	if ($test == "03 12" ) {
    		echo 'December 3<br /><img src="header.png" alt="" />';
    	}
    	if ($test == "02 12" ) {
    		echo 'December 2<br /><img src="header.png" alt="" />';
    	}
    	if ($test == "04 12" ) {
    		echo 'December 4<br /><img src="header.png" alt="" />';
    	}
    ?>

  9. #9
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Er ... something weird just happened!

    I offered advice on a programming problem!!! This if officially my first ever attempt at helping someone with a programming issue. Jeepers, I thought I'd never learn anything about programming. This is however about the limit of my abilities :P

  10. #10
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $holidays = array(
        
    '11/22' => 'thanksgiving.jpg',
        
    '12/25' => 'christmas.jpg',
        
    '1/1' => 'newyears.jpg',
        
    '9/1' => 'laborday.jpg'
    );

    if (
    in_array(date('n/j'), $holidays)) {
      
    $logo $holidays[date('n/j')];
    } else {
      
    $logo "normal_logo.jpg";
    }

    echo 
    '<img src="' $logo '" />'
    You'll still have to fix the dates for holidays that don't fall on a specific date each year, or else code in the logic for determining the date of those holidays.

  11. #11
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's kind of how I would have gone about it myself, Dan.

  12. #12
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, well that looks a little more graceful than my route. I'll need to figure out how these array thingies work some time.

  13. #13
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In this case, it's pretty easy, Ryan. You have a bunch of content you want to use (in this case, dates that have images associated with them), so you create a variable to store a list of that content (an array). Then you write a function that checks the dates in the array, and if they match, the special logo for that day gets served instead of the regular one. If none match, then the regular logo gets sent to the browser instead.

    That's the way I see it anyway.

  14. #14
    SitePoint Addict BlazeMiskulin's Avatar
    Join Date
    May 2007
    Location
    Wisconsin
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow!

    Thanks guys! That's exactly what I needed.
    M Blaze Miskulin
    President
    Geek Niche Web Hosting

  15. #15
    SitePoint Zealot purplefdu's Avatar
    Join Date
    Jul 2007
    Location
    Maine, US
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet, this is something I will definitely have to try and use on my blog. I never get enough time to make special headers as the holidays switch, but if I could make them in one sitting and have them switch by themselves it would be great. Thanks for sharing the great codes.
    Homeward Bound Puppy now with a store!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •