Query Problems
-
I am trying to run a specific query to pull only posts from a specific catergory. The catergory id is alled e-backpack and the id is 4. I have no idea where I went wrong in this. I have looked into so many posts and still no avail. Can someone please help
<div id="homepagetop"> <div class="hptop"> <h3 style="padding-bottom: 20px;">E-Backpack</h3> <?php $querystr = " SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE $wpdb->term_taxonomy.term_id = 4 AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->posts.post_status = 'publish' AND $wpdb->postmeta.meta_key = 'ebackpack' AND $wpdb->postmeta.meta_value = '$today' ORDER BY $wpdb->postmeta.meta_value ASC LIMIT 1 "; $show = $wpdb->get_results($querystr, OBJECT); ?> <?php if ($pageposts): ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <div class="newsicon"> <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a> <?php else: ?> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a> <?php endif; ?> </div><!-- end newsicon --> <div class="newsbody"> <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h3> <p>Posted <?php the_time('F j, Y'); ?></p> <?php the_excerpt(); ?> </div><!-- end newsbody --> <div style="border-bottom:1px dotted #BBBBBB; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div> <?php endforeach; ?> <?php else : ?> <p class="center">No announcements at this time.</p> <?php endif; ?> </div><!-- end hptop --> </div><!-- end homepagetop -->
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Query Problems’ is closed to new replies.