在插件中访问帖子自定义变量 - Wordpress

时间:2010-09-24 10:03:31

标签: php wordpress wordpress-plugin

我在插件中尝试了以下方法:

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;
}

遗憾的是,这不会返回任何值:(


任何想法的人?

1 个答案:

答案 0 :(得分:0)

通过使用以下内容修复帖子ID:

$featuredPosts->posts[$i]->ID