Wacław Jacek

WP Gotcha #2: WP_Query and get_posts() have different defaults

Wacław Jacek

  • WP Gotcha #2: WP_Query and get_posts() have different defaults

    Jan 9, 2023
    WordPress

    There are the following ways of getting a collection of posts in WordPress: What is the difference between WP_Query and get_posts()? get_posts() actually uses a WP_Query object under the hood. The unexpected thing it does, though, is set up the WP_Query object with a bunch of defaults that alter WP_Query‘s default behavior instead of using…

  • Registering callbacks with variable-name WordPress hooks

    Mar 22, 2022
    WordPress, WordPress patterns

    Some action and filter names used by WordPress and plugins have variable names like this one: If you only care about one specific value of $key or the value is fairly predictable, that’s pretty OK (although still has the drawback of reduced searchability). If, however, you would like to register a callback for any value…

  • WP Gotcha #1: Passing an empty array as a WP_Query parameter

    Apr 15, 2020
    WordPress
    WordPress Gotchas, WP_Query

    With this article, I would like to start a series called WP Gotchas. In it, I will describe some problems you might and probably will run into as a WordPress plugin developer – if you haven’t already. At one point I was caught off-guard by them. Maybe this post will help you if you ever…

  • Programmatically checking WordPress plugin dependencies

    Oct 18, 2018
    WordPress

    Sometimes a WordPress plugin you are writing extends the functionality of another plugin or simply relies on it to work. In these cases, you need to make sure the plugins your plugin depends on are installed and active to be sure you can use their functionality. There are some existing libraries that you can use…

© Wacław Jacek <waclawjacek@gmail.com>