• Hi all,
    I do apologize is this has been addressed over and over but I’ve googled and all I’ve found is tutorials and articles about feature images.

    I have a handful of images on homepage that I want to be able to change periodically through WordPress UI, I.e. by going through a media manager or something like that rather than changing the IMG SRC in the code. Can anyone provide any direction as to what WordPress code or php that has to replace the HTML in order to achieve this?
    The images have a particular layout, one large image on the left with 4 thumbnail sized images next to it on the right that will not be changing at all.

    Thanks for the time and help in advance.

    Brendan

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Brendan,

    First i am assuming there will be just these 4 pictures.

    You can create 4 different pages by the name like Homeimage1, Homeimage2 etc. Then go to list of pages click on the “Edit” link, now from the browsers url you can see the post id of each pages (For example it says like post=336).

    Paste this code in that particular file:

    <?php
    $image1 = wp_get_attachment_image_src(get_post_thumbnail_id(336), 'large'); //replace 336 with one of your newly created 4 pages id
    $image2 = wp_get_attachment_image_src(get_post_thumbnail_id(post id), 'large'); //replace postid
    $image3 = wp_get_attachment_image_src(get_post_thumbnail_id(post id), 'large'); //replace postid
    $image4 = wp_get_attachment_image_src(get_post_thumbnail_id(post id), 'large'); //replace postid
     ?>

    Then replace the image sources like this:

    <img src="<?php echo $image1[0];?>
    <img src="<?php echo $image2[0];?>
    <img src="<?php echo $image3[0];?>
    <img src="<?php echo $image4[0];?>

    Hope this helps,

    Regards,
    Debabrata

    Thread Starter breno785au

    (@breno785au)

    That’s wonderful, thank you for your help. I’ll give that a go tonight. And assuming with this method I’ll be retaining all stylings applied to the images?

    Good to hear from you. Yes this method will retain all stylings applied to the images.

    Feel free to ask if you stuck somewhere..!!

    Thread Starter breno785au

    (@breno785au)

    Hi, sorry, so for example do I place this code `<?php
    $image1 = wp_get_attachment_image_src(get_post_thumbnail_id(336), ‘large’);`
    into the newly created page for the first image? And then do the same with all the rest?

    And then replace the img src with the php code.

    Thanks again for your help!

    OK, here is what I have done. I put this code into the PHP file for the page, but the image isn’t showing, I know I didn’t do it right.

    <div class=”holder-middle”>
    <?php
    $image1 = wp_get_attachment_image_src(get_post_thumbnail_id(1036), ‘large’);
    ?>
    <img src=”<?php echo $image1[0];?>” >
    </div>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Changing images through WordPress UI’ is closed to new replies.