jarvis Posted August 18, 2011 Share Posted August 18, 2011 Hi, I've setup custom taxonomies called months and years Months has dec-jan feb-mar apr-may etc Years has 2011 2010 2009 I can then assign a post to a month and a year What I'm trying to do is then get a page to show all posts as follows: aug - sept 2011 - post 1 - post 2 jun - jul 2011 - another post - another post However, I can't get my code to work, here's my query: $querystr = " SELECT * FROM $wpdb->posts 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) LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) WHERE $wpdb->posts.post_type = 'post' AND $wpdb->posts.post_status = 'publish' AND $wpdb->term_taxonomy.taxonomy = 'months' ORDER BY $wpdb->term_taxonomy.taxonomy = 'years' DESC "; I then use: <?php $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <?php if ($pageposts): ?> <?php global $post; ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a><br> <?php endforeach; ?> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> But it just shows a list of posts. It doesn't order them and I can't work out how to add the headings Can someone help? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.