Insert img in wordpress page theme


/ Published in: PHP
Save to your folder(s)

Insert banner image in wordpress page theme


Copy this code and paste it in your HTML
  1. <?php if ( is_page(array(1,2,3)) ) {
  2. // the page is "About", or the parent of the page is "About"
  3. $bannerimg = '1';
  4.  
  5. } elseif ( is_pagearray(4)) ) {
  6. $bannerimg = '2';
  7.  
  8. } elseif ( is_page('home') ) {
  9. $bannerimg = '3';
  10.  
  11. } else {
  12. $bannerimg = '4';
  13. } ?>
  14.  
  15. <img src="<?php bloginfo('template_url'); ?>/images/image_<?php echo $bannerimg ?>.jpg" alt="<?php the_title(); ?>">

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.