WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Image only on Index page (5 posts)

  1. trebuchet
    Member
    Posted 8 years ago #

    How do I make an image appear only on the first page? I have set up the blog to appear on the first page of the site, and have the blog files in a separate directory. That is all working great.

    But I want to have a particular image appear on the first page, but not on any of the rest of the pages (neither blog nor static).

  2. moshu
    Member
    Posted 8 years ago #

    You will have to use a conditional tag (like "is_home")
    See more: http://codex.wordpress.org/Conditional_Tags

  3. trebuchet
    Member
    Posted 8 years ago #

    Sorry to be lame, I'm not much of a programmer, but am trying to learn as I go...

    Could I put a bit of code on the top of my index page in the themes that says to check if_home and use header1, and else, use header2?

    <?php if (is_home()) { ?>
    <?php get_header(header1); ?>

    <?php } else { ?>
    <?php get_header(header2); ?>

  4. moshu
    Member
    Posted 8 years ago #

    Yes and no.
    Yes - you can use conditionals for that.
    No - this line <?php get_header(header1); ?> will not work. get_header() is a function defined in the WP code, so that works. Anything else, not being defined in the core files - just doesn't work.

    (and your initial question was completely different: it was about an image, not about another header file...)

  5. journeyguy
    Member
    Posted 7 years ago #

    This is what I'm trying to do... place two banner ads over the header on my blog on the main page and main page only.

    If the images were ad1.jpg and ad2.jpg, how would I use the code to do that?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags