jarvis Posted August 3, 2010 Share Posted August 3, 2010 Hi All, I hope someone can help. I've got the following code in my index.php file to sort the posts by date d/m/y then title. <?php $posts = query_posts( $query_string . 'meta_key=Day&meta_key=Month&meta_key=Year&order=asc' ); ?> <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <!-- listings_wrapper --> <div id="listings_wrapper"> <!-- listings_content --> <div id="listings_content"> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> <p><?php $key="Venue"; echo get_post_meta($post->ID, $key, true); ?></p> <p><span><?php $key="Date"; echo get_post_meta($post->ID, $key, true); ?></span></p> <p><a href="<?php the_permalink() ?>">more info</a></p> </div> <!-- /listings_wrapper_content --> <!-- listings_thumbnail --> <div id="listings_thumbnail"> <?php the_post_thumbnail( 'listings-post-thumbnail' ); ?> </div> <!-- /listings_wrapper_thumbnail --> </div> <!-- /listings_wrapper --> <?php endforeach; ?> <?php else: ?> <p><?php _e('Sorry, no events matched your criteria.'); ?></p> <?php endif; ?> This works well. I'd also like this to work on my archive.php file to replace: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <!-- listings_wrapper --> <div id="listings_wrapper"> <!-- listings_content --> <div id="listings_content"> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> <p><?php $key="Venue"; echo get_post_meta($post->ID, $key, true); ?></p> <p><span><?php $key="Date"; echo get_post_meta($post->ID, $key, true); ?></span></p> <p><a href="<?php the_permalink() ?>">more info</a></p> </div> <!-- /listings_wrapper_content --> <!-- listings_thumbnail --> <div id="listings_thumbnail"> <?php the_post_thumbnail( 'listings-post-thumbnail' ); ?> </div> <!-- /listings_wrapper_thumbnail --> </div> <!-- /listings_wrapper --> <?php endwhile; else: ?> <p><?php _e('Sorry, no events matched your criteria.'); ?></p> <?php endif; ?> However, when i do that and search by category, it just returns nothing. As soon as I put the code back, it works but not displaying any order, it just shows the posts. The category list is generated from: <?php wp_list_categories( 'hide_empty=0&order=ASC&title_li&exclude=3,8' ); ?> What am I doing wrong? TIA 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.