• Hi
    I am using my own theme. Right now, I have one static image on each page in the middle of the page. How can I have different image on each page? Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi Suk,
    if you know the page ID’s of each page (say you have a fixed number of options), then you can create a conditional statement that displays only the image with a class that matches that of the body for that page.

    If you were to share your site URL, that would make it easier to provide you with a working example.

    Best!
    Steve

    Thread Starter sukhcf2

    (@sukhcf2)

    Thanks for the reply. It’s not hosted at the moment. I am just using wamp right now. Are you suggesting something like this? Please advise.

    <img src=”https://localhost/wp-content/themes/one/images/&lt;?php
    if (is_page(1)) {
    print ‘image1.jpg” />’;
    }elseif (is_page(2)) {
    print ‘image2.jpg” />’;
    }else {
    print ‘image3.jpg” />’;
    ?>

    yes… but you don’t need the print part… just declare the html for the image like:

    <?php if (is_page(1)) { ?>
    <img src=”https://something.jpg”></img&gt;
    <?php else if …

    and so on

    Thread Starter sukhcf2

    (@sukhcf2)

    Is there anyway to make it dynamic? I mean controllable through admin panel. Could custom fields be used?

    Sure you could…you just have to add the meta boxes in theme customizer to match up images with the proper page ids. This would be a great project to sub out if you haven’t done it before.

    Best!
    steve

    Thread Starter sukhcf2

    (@sukhcf2)

    Thanks Steve. I’ll give that a try. I am kinda drawn blank right now as this is my first wordpress site. But I’ll research online about what you said and see how it goes.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Different image on each page’ is closed to new replies.