WordPress.org

Ready to get started?Download WordPress

Forums

Dynamically Change Static Page Images (6 posts)

  1. nickfogle
    Member
    Posted 1 year ago #

    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" />
    }
    ?>
  2. esmi
    Forum Moderator
    Posted 1 year ago #

    <?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" />
  3. nickfogle
    Member
    Posted 1 year ago #

    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?

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    I have no idea where line 60 is...

  5. nickfogle
    Member
    Posted 1 year ago #

    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.

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

Topic Closed

This topic has been closed to new replies.

About this Topic