• 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>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Your answers — https://codex.www.ads-software.com/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.

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditional statement for flash and image rotate’ is closed to new replies.