我正在尝试以下操作(这是一个新模板中的边栏小部件):
<ul class="featured-jobs">
<?php
$postid = $post->ID;
$categories = get_the_category($post->ID);
?>
<h2><?php echo $postid; ?></h2>
<h2><?php echo $categories; ?></h2>
<?php // Create and run custom loop
$args=array(
\'post_type\' => \'news\',
\'category__in\' => $categories,
\'post__not_in\' => $postid,
\'posts_per_page\'=> 3 // Number of related posts that will be shown.
);
$custom_posts = new WP_Query();
$custom_posts->query( $args );
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<li class="see-all-positions"><a href="http://www.pixelmatic.com/open-jobs/">See All Positions >></a></li>
</ul>
但事实证明,
$postid
出现空白并且
$categories
输出组件
Array
.
我做错了什么?