Support » Networking WordPress » Dynamically Change Static Page Images

  • HI, this is my first post for help in wordpress, and man do I really need it. This is the first time I’ve developed a client’s site using multisite, and I’m having trouble applying the appropriate header image to it’s site. There are six sites in all, and I’m using the same template for all six sites’ front pages. Also, the front page is static and doesn’t have a specific page selected.

    The conditional below is my attempt at specifying specific images depending on which sub-site I’m on. It keeps throwing a syntax error, (sublime calls it a parse error). I would be so grateful for any help!

    <?php
    if( get_bloginfo('All in with Laila Ali')) {
       <img src="<?php bloginfo('template_directory');?>/images/Banner-LailaAli.jpg" />
    } elseif{
       if( get_bloginfo('Jaimies 15 Minute Meals')) {
       <img src="<?php bloginfo('template_directory');?>/images/Banner-JamieOliver.jpg" />
    }
    } elseif{
       if( get_bloginfo('Lucky Dog')) {
       <img src="<?php bloginfo('template_directory');?>/images/Banner-LuckyDog.jpg" />
    }
    } elseif{
       if( get_bloginfo('Game Changers with Kevin Frazier')) {
       <img src="<?php bloginfo('template_directory');?>/images/Banner-GameChangers.jpg" />
    }
    } elseif{
       if( get_bloginfo('Recipe Rehab')) {
       <img src="<?php bloginfo('template_directory');?>/images/Banner-RecipeRehab.jpg" />
    }
    } else {
       <img src="<?php bloginfo('template_directory');?>/images/Banner-PetVet.jpg" />
    }
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    Forum Moderator

    <?php
    if( get_bloginfo('All in with Laila Ali')) :?>
       <img src="<?php bloginfo('template_directory');?>/images/Banner-LailaAli.jpg" />
    <?php elseif( get_bloginfo('Jaimies 15 Minute Meals')) :?>
       <img src="<?php bloginfo('template_directory');?>/images/Banner-JamieOliver.jpg" />
    <?php elseif( get_bloginfo('Lucky Dog')) :?>
       <img src="<?php bloginfo('template_directory');?>/images/Banner-LuckyDog.jpg" />
    <?php elseif( get_bloginfo('Game Changers with Kevin Frazier')) :?>
       <img src="<?php bloginfo('template_directory');?>/images/Banner-GameChangers.jpg" />
    <?php elseif( get_bloginfo('Recipe Rehab')) :?>
       <img src="<?php bloginfo('template_directory');?>/images/Banner-RecipeRehab.jpg" />
    <?php else :?>
       <img src="<?php bloginfo('template_directory');?>/images/Banner-PetVet.jpg" />

    Thanks so much for your fast response! I replaced the existing code with yours and this is what I’m getting:

    ‘Parse error: syntax error, unexpected $end in /home/cbsdream/public_html/wp-content/themes/CBS/home.php on line 60’

    Any ideas on what else might be causing the problems?

    esmi

    (@esmi)

    Forum Moderator

    I have no idea where line 60 is…

    I’ve been troubleshooting this thing all day, and can’t get it to work. Could you think of any other ways to achieve the same result. Thank you for your help.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    Why not just grab the blog ID?

    <?php global $blog_id; ?>
    
    <img src="<?php bloginfo('template_directory');?>/images/Banner-<?php echo $blog_id; ?>.jpg" />

    So then you have Banner-1.jpg and so on.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Dynamically Change Static Page Images’ is closed to new replies.