Need to echo page-id and postid from body_class results
-
I’m using a page background ‘trick’ to display an image as the page background, which stretches to always fit the browser view port.
It requires this code just after the body tag:
<div id="page-background"><img src="' . get_bloginfo('template_directory'). '/images/page-id-2.jpg" width="100%" height="100%" alt=""></div>
And this in the stylesheet:
#page-background {position:fixed; z-index:0; top:0; left:0; width:100%; height:100%;}
But I want to dynamically change the image name based on what page you’re on, or if on a single post, display ‘postid’, both of which are spit out as a class for the body, since I’m using the body_class(); tag.
So I need the php tag to dynamically change the image name
<div id="page-background"><img src="' . get_bloginfo('template_directory'). '/images/' . what_tag_goes_here?(). '.jpg" width="100%" height="100%" alt=""></div>
Thanks
- The topic ‘Need to echo page-id and postid from body_class results’ is closed to new replies.