Overview

Use this tool to create custom code for WordPress Query with WP_Query class.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.

Examples

If you are still learning how to use this tool, check out the following examples:

The variable used in the code.
Show The Loop.
Display post by ID. Display post by slugs.
Display page by ID. Display page by slugs.
Display child-pages of a parent-page id.
Display posts by post type. Display posts by post status.
Display posts by Category ID. Display posts by category name (slug).
Display posts by tag ID. Display posts by tag name (slug).
Display posts by author ID Display posts by author 'user_nicename'.
Show all posts or use pagination. Show posts in page number X.
Number of post to show per page. Number of post to show per archive page.
Show or ignore sticky posts. Number of post to displace or pass over.
Ascending or Descending order. Sort retrieved posts by.
Display posts by with this custom field key. Display posts by with this custom field value.
Operator to test the custom field value. Custom field type.
Display posts if user has the appropriate capability.
Display posts with/without caching post information.
Display posts with/without caching post meta information.
Display posts with/without caching post term information.

  Save Snippet
// WP_Query arguments
$args = array (
);

// The Query
$query = new WP_Query( $args );