ForEach Question

Hi! The following query works, but there are no results. Nothing displays. I need it to list out my category posts. I believe I am erring with how I am using foreach. Any help would be appreciated. I already tried the Wordpress forums, but I swear the mods over there are Nazis, lol. THANKS!

[php]function get_cat_posts( $cat, $qty )
{

global $wpdb;

$querystr = "
SELECT *
FROM $wpdb->wp_posts as wpost
INNER JOIN $wpdb->wp_term_relationships
ON wpost.ID = $wpdb->wp_term_relationships.object_id
INNER JOIN $wpdb->wp_term_taxonomy
ON $wpdb->wp_term_relationships.term_taxonomy_id = $wpdb->wp_term_taxonomy.term_taxonomy_id
AND $wpdb->wp_term_taxonomy.taxonomy = ‘category’
AND $wpdb->wp_term_taxonomy.term_id IN (24)
LEFT OUTER JOIN $wpdb->wp_q2w3_post_order
ON wpost.ID = $wpdb->wp_q2w3_post_order.post_id
ORDER BY $wpdb->wp_q2w3_post_order.post_rank;
";

$pageposts = $wpdb->get_results($querystr, OBJECT);

$returnThis = ‘’;

$returnThis .= ‘

    ’."\r\n";

    foreach ( $pageposts as $post )
    $returnThis .= “\t”.’

  • ’.$post->post_title.’
  • ’."\r\n";

    $returnThis .= ‘

’."\r\n";
	return $returnThis;
}

}
[/php]

Echo your query string, and check that it is what you want. I don’t think you can use object withing a double quoted string like you are using. If thats the case encase those objects with curly braces,

Sponsor our Newsletter | Privacy Policy | Terms of Service