Php 在插件中访问post自定义变量-Wordpress
我在插件中尝试了以下方法:Php 在插件中访问post自定义变量-Wordpress,php,wordpress,Php,Wordpress,我在插件中尝试了以下方法: get_post_meta($featuredPosts[$i]->ID, "Thumbnail", true); 在以下插件代码中: $featuredPosts = new WP_Query(); $featuredPosts->query('showposts=5&cat=1'); for($i=1; $i<=$featuredPosts; $i++) { // second for() loop for post slides
get_post_meta($featuredPosts[$i]->ID, "Thumbnail", true);
在以下插件代码中:
$featuredPosts = new WP_Query();
$featuredPosts->query('showposts=5&cat=1');
for($i=1; $i<=$featuredPosts; $i++) { // second for() loop for post slides
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); // loop for posts
get_post_meta($featuredPosts[$i]->ID, "Thumbnail", true);
endwhile;
}
$featuredPosts=new WP_Query();
$featuredPosts->query('showposts=5&cat=1');
对于($i=1;$ihave_posts()):$featuredPosts->the_post();//帖子循环
获取帖子元($featuredPosts[$i]>ID,“缩略图”,true);
结束时;
}
不幸的是,这不会返回任何值:(
有什么想法吗?通过使用以下方法获得帖子ID进行修复:
$featuredPosts->posts[$i]->ID