Problems with Custom Loop in a Page
-
Hi all!
Not sure what I’m doing wrong here, I have a custom loop within a page (separate from the main blog) from which I’d only like to pull posts from Cat. 4.
Any ideas where I’m going wrong?
Thank you!!!
<?php /* Template Name: Providers */ get_header(); ?> <div id="content"> <?php global $wpdb; global $post; $querystr = " SELECT wposts.* FROM $wpdb->posts wposts LEFT JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id LEFT JOIN $wpdb->term_relationships ON (wposts.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.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id IN('4') ORDER BY wpostmeta.meta_value ASC "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <?php if ($pageposts): ?> <?php global $post; ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <div class="post" id="post-<?php the_ID(); ?>"> <!-- POST TITLE--> <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3> <!-- POST META--> <!-- POST CONTENT--> <div class="storycontent"> <div class="postthumb"><?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(200,200), array("class" => "alignleft post_thumbnail")); } ?></div> <div class="postexcerpt"><?php the_content(__('(more...)')); ?></div> </div> </div> <!-- END POST LOOP--> <?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Problems with Custom Loop in a Page’ is closed to new replies.