How to get page ID from inside header.php ?
-
Hi,
I’m trying to get the value of a custom field from within header.php. I ‘ll then use the value to decide which images to display in a banner inside the header.
Just to clarify, this is for a page, not a post.
I can use the following code OK within page.php
<?php echo 'custom data: ' . get_post_meta(get_the_ID(), 'banner_images', true); ?>but if I try it inside header.php then nothing is returned by get_post_meta()
I’ve tried using $pot->ID to retrieve the page id, but that doesn’t work either.
I don’t want to hard-code the page id, as that kind of defeats the object.
Any suggestions?
Cheers,
Nick
The topic ‘How to get page ID from inside header.php ?’ is closed to new replies.