I have create a custom post object with custom post metas.
Like this:
$post->custom_meta = get_post_meta();
$custom_post = $post;
Am I how to define the $custom_post
object to global in master level?
Can I request any file it like single.php
global $custom_post;
the_title();
echo $custom_post->custom_meta;
or index.php
global $custom_post;
// The Loop
if ( $custom_post->have_posts() ) {
echo '<ul>';
while ( $custom_post->have_posts() ) {
$custom_post->the_post();
echo '<li>' . get_the_title() . '</li>';
echo $custom_post->custom_meta;
}
echo '</ul>';
} else {
// no posts found
}
How to set $custom_post
an global and in where? (functions.php
?) thx.