Writing a WordPress Plugin From Scratch: A Step-by-Step Tutorial
This WordPress plugin development tutorial captures the steps I went through on a real project, including the mistakes I made and how I debugged them.
Simple WP_Query Example: Using a Shortcode to Display Post Titles
In this video and text Quick Guide, we present a basic use of WP_Query inside a WordPress shortcode, to show the post titles of the five most recently published posts. We’ve designed this Quick Guide to be a simple intro to using WP_Query in general, as well as to using WP_Query to display post titles and other post data inside a shortcode specifically.
get_queried_object(): How and Why to Use It
WordPress’s get_queried_object() function has the distinction of being, I think, the most useful core function in WordPress that I didn’t know about for the longest time.
How to Sort Posts by their Taxonomy Terms
Don’t Cache WP_Query Objects (and Why Not)
Recently, I was working on site speed for a client with one page that makes a large number of custom database queries through WordPress’s WP_Query API.
How to Paginate a Custom WP_Query: Stack Overflow to the Rescue
Something I can’t remember needing to do before is to paginate a custom WP_Query. (Maybe my memory’s failing me, since this is what you’d need to know how to do to put post content at the top of an archive page—one of the weirdest and most common “Why can’t WordPress do that?” things in my experience.)
How to Write a WP_Query for Multiple Specific Post IDs
Recently, a client project I’m working on required something I don’t think I’ve done before: write a WP_Query to fetch a dynamically generated list of post IDs.
Creating a WordPress Widget to Show a Random Post
Making a widget to show a random post uses two underlying concepts you need to get familiar with to be good at WordPress development: making use of WP_Query objects, and making widgets. If you’ve not checked them before, check out our Quick Guides which more thoroughly introduce both:
Making your First WordPress Plugin (From Scratch): Live Training Tomorrow
We’re doing a WordPress development training session tomorrow!
WP_Query vs query_posts() vs get_posts()
This is not a new resource, but I just rediscovered and found it still incredibly relevant. Back in 2011, Andrey “Rarst” Savchenko put together a little diagram that shows the difference between three of the most common ways of dealing with getting posts in WordPress, a new WP_Query object, or the query_posts() or get_posts() functions.