Conditional Meta Data or Custom Fields
-
I’m working on displaying the title from a custom post type (Stores) in a list of Stores. Within the custom post type, I have a custom field which places some of stores in a different premium category.
As such, if the store is considered to be premium, I would like to display the premium Stores first, then the other stores after (so I can style them differently (example)
So far, my code looks like:
<?php $args = array( 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'title', 'post_type' => 'store' ); query_posts($args); if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <p class="directory"> <a href="<?php echo get_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p> <?php endwhile; ?> <?php else : ?> <h3 class="post-title">No Stores Found</h3> <p>We're sorry, but there are no stores currently available for display. Please return soon.</p> <p> <a href="<?php echo get_option('home'); ?>">Return to the homepage</a> </p> <?php endif; wp_reset_query(); ?>
How can I check to see if the meta field has data, and if it has data, display them first?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Conditional Meta Data or Custom Fields’ is closed to new replies.