[wp-hackers] How to make $post->ID global

Ryann Micua ryannmicua at gmail.com
Sat May 12 01:54:49 UTC 2012


Based on what David is doing, I'd suggest creating a template tag 
(function) in your functions.php file along the lines of:

function show_random_header_image(){

global $post;
$stmeta2011headeror = get_post_meta($post->ID, 'st_meta_2011header_or', 
true);

//do random image stuff

return $stmeta2011headeror;

}

then in your header.php template

use your function

<body>
...
<div id="header-image">
<?php echo show_random_header_image(); ?>
</div>
...

your REAL problem is not getting the $post ID. It's showing random image 
from a set for a post where it is possible to select specific header 
image set for a post.

Good thing you included your use case :)

On Friday, 11 May, 2012 04:01 PM, 
wp-hackers-request at lists.automattic.com wrote:
> Trying to use the post id in an included php file which is basically an extension of functions.php (tried the code in functions.php as well with no success).

-- 
*Ryann Micua*
/Web Developer/
------------------------------------------------------------------------

Website: /www.pogidude.com/
Skype: /rmicua/
Mobile: /+639169273059/



More information about the wp-hackers mailing list