WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How can I show a different image on each page? (8 posts)

  1. carrieduncan
    Member
    Posted 4 years ago #

    Here's a link for a Page based on the current Page template:

    http://0055ae0.netsolhost.com/wordpressLR/?page_id=12

    Styles for image and right column are in the HTML (in the Page content itself). This bumps the Edit link to the left of the column (which you won't be able to view) instead of right aligning (as set in the rule).

    I'd prefer to have all the CSS in the Page template rather than in the HTML, but can't figure out how to give each page a different image if I do it that way. There will be about five pages. (SO new at this: 3 wks and counting.)

    Thanks very much in advance for any help you can provide.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    This might be a lot easier if you looked at setting up custom page templates. That way, you could have unique classes for each page type which you could then use in your stylesheet instead of having CSS in the page. You might also want to have a look at the is_page() conditional to control what image appears in what page.

  3. Nile Flores
    Member
    Posted 4 years ago #

    Well, here is one way I did this on one site, so maybe it might work for you.

    If you are not using a sidebar, you should consider it. So you will have a left column and right column. Left would be for your sidebar, and the right, of course... your content.

    Using the dynamic sidebars, you will be able insert the image into a widget and it will appear on the page.

    You will need to have several sidebars for your site if you want a different image for each page.

    I recommend if you have not already, try reading since you are new. Esmi has some recommendations for this. It is not difficult, and if you download a free template, you can look at the files to get an idea on what to do. :) I use to find that it helps to do that.
    http://codex.wordpress.org/Stepping_Into_Templates

  4. carrieduncan
    Member
    Posted 4 years ago #

    Many thanks to you both for your on-the-quick response -- The is_page() conditional is exactly what I was looking for (thanks especially, esmi, for your links here and for your countless answers elsewhere) as I'd hoped to eliminate the custom page I'd already had to make. Posting an interim thank you because as I was trying to work with this, I broke my site but good. (Validated backup templates notwithstanding.) (Float: left in one of the divs renders the page blank in IE8. Oh, IE.)

    Since then, I've been at it for about 10 hours and counting attempting to get back to the perfect layout I had (in both FF and IE8), but will come back and post what did work once I've 1) fixed it the layout and 2) figured out how to place the image src code within the conditional php code.

  5. carrieduncan
    Member
    Posted 4 years ago #

    I tried Sidebar Generator, which worked fine with one sidebar defined and selected, but more than one kicked out 2 or 3 different images per page.

    Next up was is_page() conditional (which was my preference), but I'm still feeling around for syntax. Can anyone tell me why this isn't working (this is what I have in my sidebar and I'm getting "unexpected $end" on the page)? Code as follows:

    <img src="http://0055ae0.netsolhost.com/wordpressLR/wp-content/themes/LR/images/<?php
    if (is_page( 'about' )) {
    print 'checkbook.jpg" />';
    }elseif (is_page( 'resources' )) {
    print 'resources.jpg" />';
    }else {
    print 'checkbook.jpg" />';
    ?>

    Thanks so much for any help you can offer.

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

    a missing closing bracket:

    }else {
    print 'checkbook.jpg" />'; }
    ?>
  7. carrieduncan
    Member
    Posted 4 years ago #

    AHHHH!!! Thank you! That worked!

  8. stevemitch
    Member
    Posted 4 years ago #

    hi
    how would i enable an image to be printed from wordpress
    its a voucher at bottom of this page here:
    http://clients.pcrepair-south.co.uk/mrstephen2010/

    many thanks
    steve

Topic Closed

This topic has been closed to new replies.

About this Topic