I’m trying to reorder my posts being queried on the page. If a particular custom field exist, I want those posts moved to the top of the loop order….then posts that don’t have the custom field come after. I’m thinking this will have to be done maybe by an array_merge but I’m not sure if there is another way. I’ve got this…..
<?php while(have_posts()) : the_post(); ?> <div class="articleContent"> <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_title(); ?> </a></h3> <small> <?php the_excerpt_rss(); ?> </small> <?php endwhile; ?>
I need to modify the above to check for meta_key called “order” and orderby the meta_value ASC. Every time I do it I end up just getting the one’s that have the custom field and it drops the posts that don’t.
- The topic ‘Custom Post Type: Order Loop if Custom Field Exsists’ is closed to new replies.