WordPress Blown: declare global $post; or you’re effed

Was tweaking a query to pull current post category and the darn thing wasn’t working right until i declared global $post; .  Just thought I’d warn the masses.  Here’s the snippet:

<?php
 global $post; //important!!
 foreach(get_the_category() as $category) {
 $cat = $category->cat_ID; }
query_posts('cat=' . $cat . '&order=DESC&showposts=-1'); ?>
 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

This entry was written by ross, posted on November 25, 2009 at 4:40 pm, filed under Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Timeline

Have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

:

: