General Post & Page Type & Status Password Author Search Pagination Order Taxonomy Date Custom Fields Permissions Cache 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: Posts by specific author name Random Quote Products up to 100$ Most popular Posts ordered by Comment Count Query Variable Name The variable used in the code. Show The Loop Yes No Show The Loop. Post ID Display post by ID. Post Name Display post by slugs. Page ID Display page by ID. Page Name Display page by slugs. Parent Display child-pages of a parent-page id. Post Type Display posts by post type. Post Status Display posts by post status. Has Password Choose... Yes No Display password protected posts. Post Password Display posts with a particular password. Author ID Display posts by author ID Author Name Display posts by author 'user_nicename'. Search Keyword Display post by keywords. Use Pagination Choose.. Yes - Default No Show all posts or use pagination. Paged Show posts in page number X. Posts per page Number of post to show per page. Posts per archive page Number of post to show per archive page. Sticky Post Choose... Yes No Show or ignore sticky posts. Offset Number of post to displace or pass over. Order Choose.. ASC DESC - Default Ascending or Descending order. Order by Choose.. None Random ID Title Slug Date - Default Modified Date Parent ID Menu Order Comment Count Sort retrieved posts by. Taxonomy Query No save snippets... Select from your saved WP_Tax_Query snippets. Date Query No save snippets... Select from your saved WP_Date_Query snippets. Meta Query No save snippets... Select from your saved WP_Meta_Query snippets. User Permission Display posts if user has the appropriate capability. Cache Results Choose... Yes No Display posts with/without caching post information. Cache Post Meta Choose... Yes No Display posts with/without caching post meta information. Cache Post Term Choose... Yes No Display posts with/without caching post term information. Update Code Save Snippet
// WP_Query arguments $args = array( 'post_type' => array( 'quotes' ), 'posts_per_page' => '1', 'orderby' => 'rand', ); // The Query $query = new WP_Query( $args );