I am attempting to create a custom page that will display all posts based that have a custom meta key of volume. While I have been searching extensively for the past 2 hours, I have come across the following posts/documents that helped to an extent.
http://wordpress.org/support/topic/sort-by-custom-value-fields
http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
As of right now my issue is that I am only returning one result instead of all. Below is my markup.
<?php
$querystr = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'volume'
ORDER BY wpostmeta.meta_value DESC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
if ($pageposts) : foreach ($pageposts as $post): setup_postdata($post);
$my_meta = get_post_meta(get_the_ID(), '_my_meta', TRUE);
?>
<div class="post">
<h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="post-info">
<span class="date time published"><?php the_time('F j, Y') ?></span> |
<?php if($my_meta['volume'] && $my_meta['volume']){ ?>
Volume <?php echo $my_meta['volume']; ?> Issue <?php echo $my_meta['volume']; ?> |
<?php } ?>
<span class="categories">Filed Under: <?php the_category(', ') ?></span>
</div>
<div class="entry-content">
<?php
//global $more;
//$more = 1;
//the_content('');
?>
</div><!-- end .entry-content -->
</div><!-- end .postclass -->
<?php endforeach; endif; ?>
Any and all help is greatly appreciated.
Thanks in advance!