• Hi there,

    I’m fairly new to wordpress, but able to convert html to a wordpress site.

    Now, i’m facing a problem with WordPress. I checked tho docs and tried a lot, but not with a satisfied outcome.

    I have a site with a main header on the front-page. This is actually a slider. This works. But for the inner-pages, I want no slider, so I created an “inner-header.php file and linked that to each “inner-page” template. So far, so good.
    This inner-header, does have an image on the right side. That image have to be changed when browsing to another page. So each page must have it’s own image in its header.

    I tried the following, but it isn’t working:

    <?php if (is_page('services')) { ?>
    <img src="<?php bloginfo('template_directory')?>/images/exper.png" alt="" />
    <?php } elseif (is_page('portfolio')) { ?>
    <img src="<?php bloginfo('template_directory')?>/images/exper1.png"
    <?php } elseif (is_page('portfolio')) { ?>
    <img src="<?php bloginfo('template_directory')?>/images/exper1.png"

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

    What i’m doing wrong and how to get it work?

    Thanks in advanced.

Viewing 4 replies - 1 through 4 (of 4 total)
  • but it isn’t working

    what is the result?

    apart from a php error because the last elseif is not closed (at least not in your posted section)?

    Thread Starter quinox

    (@quinox)

    Hi there,

    Sorry for my incorrect post. This is the code I’m using:

    <div class="title-img">
                            <?php if (is_page('services')) { ?>
                                    <img src="<?php bloginfo('template_directory')?>/images/exper.png" alt="" />
                            <?php } elseif (is_page('portfolio')) { ?>
                                    <img src="<?php bloginfo('template_directory')?>/images/exper1.png" />
                            <?php } elseif (is_page('portfolio')) { ?>
                                    <img src="<?php bloginfo('template_directory')?>/images/exper1.png" />
                            <?php endif; ?>
                    </div>

    This is the error message i’m getting:

    Parse error: syntax error, unexpected T_ENDIF in /home/vanschen/public_html/wordpress/wp-content/themes/vanschendel/header_inner.php on line 96

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Why are there two elseifs that are the same?

    Thread Starter quinox

    (@quinox)

    Yes, you’re right. Got it working now!

    Thanks for your help.

    Regards,

    Roland

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘different image in different pages’ is closed to new replies.