iarp Posted October 18, 2008 Share Posted October 18, 2008 I have these 2 query's each grab certain types of posts according to their category SELECT post.ID, post.post_title, terms.name FROM $wpdb->posts AS post, $wpdb->terms AS terms, $wpdb->term_relationships AS tr WHERE (post.ID = tr.object_id) AND (tr.term_taxonomy_id = terms.term_id) AND terms.name = 'Newsletter' AND post.post_status = 'publish' AND post.post_date_gmt < '$today' AND post.post_type != 'page' ORDER BY post.post_date DESC LIMIT 5")) { ?> and SELECT post.ID, post.post_title, terms.name FROM $wpdb->posts AS post, $wpdb->terms AS terms, $wpdb->term_relationships AS tr WHERE (post.ID = tr.object_id) AND (tr.term_taxonomy_id = terms.term_id) AND terms.name = 'Events' AND post.post_status = 'publish' AND post.post_date_gmt < '$today1' AND post.post_type != 'page' ORDER BY post.post_date DESC LIMIT 10")) { Both are basically the same exact one terms.name = '' says Newsletter and ones Events. Having both of those query's in my sidebar.php page... the actual < a > link part is fine and works, but the_title() displays the last result of the first query Any insight what i can do to clear the_title or something. I've tried <?php $wpdb->flush(); ?> everything and it doesn't work... even right after the query themselves. This is the output code: <?php $today1 = current_time('mysql', 1); if ( $eventposts = $wpdb->get_results( " SELECT post.ID, post.post_title, terms.name FROM $wpdb->posts AS post, $wpdb->terms AS terms, $wpdb->term_relationships AS tr WHERE (post.ID = tr.object_id) AND (tr.term_taxonomy_id = terms.term_id) AND terms.name = 'Events' AND post.post_status = 'publish' AND post.post_date_gmt < '$today1' AND post.post_type != 'page' ORDER BY post.post_date DESC LIMIT 10")) { ?> <ul> <?php foreach ($eventposts as $post1) { if ($post1->post_title == '') $post1->post_title = sprintf(__('Post #%s'), $post1->ID); echo "<li><a href='".get_permalink($post1->ID)."'>"; the_title(); echo '</a></li>'; } ?> </ul> <?php } else { ?> <ul> <li>No Events at this time</li> </ul> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/128939-solved-wordpress-2-querys-one-the-same-page-need-to-clear-the-first/ Share on other sites More sharing options...
iarp Posted October 18, 2008 Author Share Posted October 18, 2008 print($post1->post_title); did the trick Link to comment https://forums.phpfreaks.com/topic/128939-solved-wordpress-2-querys-one-the-same-page-need-to-clear-the-first/#findComment-668495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.