php - How to fetch the page id and use it for an image name -
i new in php. want make condition showing page id , set image name pageid , show background image in header banner. how fetch page id use fetching image banner background img.
here code:
<div class="splash"> <img src="<?php echo get_template_directory_uri(); ?>/images/<?php echo $page;?>.jpg" /> </div> and working in loop in different page change header banner image if change page.
i have problem in code. working fine pages if go inner pages or post of page shows banner want hide that. how can it
you're close...assuming you're on single post/page template, can use get_the_id():
<img src="<?php echo get_template_directory_uri() . '/images/' . get_the_id() . '.jpg'; ?>" />
Comments
Post a Comment