WordPress.org

Ready to get started?Download WordPress

Forums

Conditional statement for flash and image rotate (3 posts)

  1. kloy
    Member
    Posted 4 years ago #

    Ok, I'm trying to get a flash banner to play on the home page.
    On all the other pages I'm want a set of random images to appear in the header. So I'm trying to create somekind of conditional statement. Both work individually. But I can't seem to get the conditional statement to work... So Iam trying to say---If at home use this html, if else , use this other html code

    <div role="banner" class="headerimg">
    <?php if (is_home()): {echo '<object width="1000" height="296">
    <param name="movie" value="ns_header.swf">
    
    <embed src="<?php bloginfo
    ('template_directory');?>/images/ns_header.swf" width="1000" height="296">
    
    </embed>
    
    </object>'};
    
    else
    {echo '<img class="headerimg" src="<?php bloginfo
    
    ('template_directory');?>/images/headerimgs/rotate.php"
    
    alt="A Random Header Image"/>'};?>
    
    </div>
  2. jimisaacs
    Member
    Posted 4 years ago #

    Your answers -- http://codex.wordpress.org/Conditional_Tags

    Functions to note: is_home(), is_front_page(), is_page()

    A small tip for conditionals is to always remember combinations and inverse usage.

  3. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    this has not much to do with conditional statements, which you are using correctly, but with the sequence of your php tags and the use of strings which you seem to ignore.
    when you echo a string, you need to use wordpress functions that reurn a string as well and concatenate them with the rest of the string:
    i.e. get_bloginfo() instead of bloginfo(); and no extra php tags.

    wonder if you're not getting any error messages?

    here an attempt to tidy your code:

    <div role="banner" class="headerimg">
    <?php if (is_home()): {echo '<object width="1000" height="296">
    <param name="movie" value="ns_header.swf">
    
    <embed src="'. get_bloginfo
    ('template_directory') . '/images/ns_header.swf" width="1000" height="296">
    
    </embed>
    
    </object>'};
    
    else
    {echo '<img class="headerimg" src="' . get_bloginfo
    
    ('template_directory') . '/images/headerimgs/rotate.php"
    
    alt="A Random Header Image"/>'};?>
    
    </div>

    hope this works.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.