I'm trying the following (it's a sidebar widget in the Single New template):
<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>
But as it turns out, $postid
comes up blank and $categories
outputs as Array
.
What am I doing wrong here?