Given the following example of a custom query

$query = new WP_Query(array(
    'posts_per_page' => 7,
    'categor_name' => 'events',
    'offset' => 5

Does the order of arguments matter?

Will this query first select all posts with the given category and then offset the first 5 or will it first offset all 5 posts then select posts with given category?

  • 1
    possible typo 'category_name' => 'events',
    – prosti
    Nov 30 '19 at 18:11

The order doesn't matter. That query will get 7 posts from the "events" category, skipping over the 5 most recent (since the default order is by date).

  • Without the typo category order doesn't matter.
    – prosti
    Nov 30 '19 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.