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.
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:
Getting to Know WP_Query
The WP_Query class is an exceptionally powerful tool in WordPress. As you may know, every WordPress site contains a database that stores many posts (of many post types) that make up the bulk of that site’s content, and WP_Query is the best way to fetch or retrieve a given selection of those posts for processing. So your theme files use it on regular basis, and a lot of plugins on your WordPress site will it.
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.
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.
Making your First WordPress Plugin (From Scratch): Live Training Tomorrow
We’re doing a WordPress development training session tomorrow!