Here’s how to build a grid layout for WordPress via shortcodes and WP_Query:
A lot of WordPress developers immediately rush to query_posts in order to create custom loops.
But, query_posts is meant for altering the main loop of a WordPress page/post (actually, it’s not even recommended for that anymore).
Using get_posts() is okay… but, if you want that real WordPress flavor using WP_Query is the way to go.
In the video above, I show you how to use WP_Query to create a custom loop inside WordPress in order to build a Pinterest-style grid layout.
Here’s the code I used in the video:
If you get value from this code snippet, please consider sharing it with another developer or group who could benefit from it.