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:



Jany Martelli

I’m a Digital Consultant, Front-End Developer, specialized in WordPress.
I help companies, professionals and startups grow with technology and a winning digital strategy, I hand-pick and coordinate the perfect team for them, plan projects from the ground-up, develop & deploy websites, online stores and apps.