WordPress.org

Ready to get started?Download WordPress

Forums

If Page Id is x insert image (3 posts)

  1. Design Locker
    Member
    Posted 1 year ago #

    Hello all,

    I have figured out how to add an image to my header area using the following code;

    <?php if (is_home()) { ?>
       <image src="<?php bloginfo('stylesheet_directory'); ?>/images/all_round_yoga_home.jpg" />
    <?php } elseif (is_page(8)) { ?>
       <image src="<?php bloginfo('stylesheet_directory'); ?>/images/all_round_yoga_therapy.jpg" /><?php } ?>

    My problem is I also need to add an image to the same area of my site for each of the six categories but I cannot figure this out.

    Page with Image: http://www.allroundyoga.ie/wip/reiki/
    Category Archive with no image: http://www.allroundyoga.ie/wip/category/yoga-for-breathing/

    As you can see on the category & post pages there are no images.

    Any help would be greatly appreciated.

  2. Design Locker
    Member
    Posted 1 year ago #

    Just figured it out if anyone is interested in the future ...

    <?php if (is_home()) { ?>
       <image src="<?php bloginfo('stylesheet_directory'); ?>/images/imagename.jpg" />
    <?php } elseif (is_page(8)) { ?>
       <image src="<?php bloginfo('stylesheet_directory'); ?>/images/imagename.jpg" />
    <?php } elseif (in_category( '5' )) { ?>
       <image src="<?php bloginfo('stylesheet_directory'); ?>/images/imagename.jpg" />
    <?php } ?>
  3. askrevill
    Member
    Posted 4 months ago #

    Thanks, this works a treat!

Topic Closed

This topic has been closed to new replies.

About this Topic