Display old posts if no future posts exist

example: <?php query_posts(‘posts_per_page=5&order=ASC&post_status=future’); if ( !have_posts() ) query_posts(‘posts_per_page=5&order=DESC&post_status=publish’); if( have_posts() ) : while ( have_posts() ) : the_post(); ?>

Query Custom Post Type and sort by year

You don’t need to create a page template to list the project post type, just go to /project/ and you’ll have a full date ordered listing. The template powering that page will be determined as follows: archive-project.php archive.php index.php So create an archive-project.php in your theme. Using this you can specify to list only the … Read more

wp query problem

While comparing numbers in meta value use “meta_value_num” instead of “meta_value” ‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’. Reference