WordPress Tricks #4


So you have custom taxonomy in your WP site, because you want some posts to be a bit more than just “Articles”, follow their own rules and be displayed in a different way maybe.

So what if you want to display, in one page, all those posts BUT first the ones with a specific custom field value?
How do you prevent the Loop to load all the posts, regardless the custom field value difference?

This is how you do it, using 2 custom Loops.

Obviously, replace the snippet with your own custom post type name and custom field name and value, where needed.

So now you’re halfway through with it, let’s see how to grab the rest of the posts, the ones that don’t have that same custom field value, and will be displayed right below all the previous ones.

This second loop, can actually be accomplished also using this snippet:

 

Enjoy!

I’m a Digital Consultant, Web Designer & Developer, specialized in WordPress.
I’ve been making websites for 17 years and have specialized in WordPress since 2009.
I like to work with PHP/MySQL, HTML5/CSS3/Javascript, Twitter Bootstrap and, of course, WordPress.
I help companies, professionals and startups grow with technology, I hand-pick the perfect team for them, plan projects from the ground-up, develop & deploy websites, online stores and apps.