admin管理员组文章数量:1310221
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.
本文标签: phpDefine global custom post
版权声明:本文标题:php - Define global custom post 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741841982a2400556.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论