Title: WP_Query syntax (The Loop)
Last modified: August 20, 2016

---

# WP_Query syntax (The Loop)

 *  Resolved [du3z](https://wordpress.org/support/users/du3z/)
 * (@du3z)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp_query-syntax-the-loop/)
 * Hi all,
 * I’m trying to ride on this code by allowing another custom post type:
    <?php 
   $recent = new WP_Query(‘post_type=listing&post_status=publish&posts_per_page=’.
   get_option(‘wp_recentlistingsnumber_home’)); ?>
 * i understand I could add in an array into the query from here:
    [http://codex.wordpress.org/The_Loop](http://codex.wordpress.org/The_Loop)
 * I’m not sure what the correct syntax, i was reading this:
    [http://codex.wordpress.org/Class_Reference/WP_Query](http://codex.wordpress.org/Class_Reference/WP_Query)
 * could i possible just add an array in this manner? …WP_Query( array(‘post_type’
   => ‘listing’,’project’))&post_status=publish&posts_per_page=’.get_option(‘wp_recentlistingsnumber_home’));?
   >

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp_query-syntax-the-loop/#post-2683261)
 * No – you cannot add a WP_Query to the standard $query. The former overwrites 
   the latter.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp_query-syntax-the-loop/#post-2683264)
 * it is basically all array or all string;
 * the moment you need one array, you need to convert the whole wp-query args to
   array syntax.
 * your example:
 *     ```
       <?php $recent = new WP_Query('post_type=listing&post_status=publish&posts_per_page='.get_option('wp_recentlistingsnumber_home')); ?>
       ```
   
 * re-written in array syntax:
 *     ```
       <?php $recent = new WP_Query( array('post_type' => 'listing', 'post_status' => 'publish', 'posts_per_page' => get_option('wp_recentlistingsnumber_home')) ); ?>
       ```
   
 *  Thread Starter [du3z](https://wordpress.org/support/users/du3z/)
 * (@du3z)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp_query-syntax-the-loop/#post-2683270)
 * ahh. i understand now =) that’s helpful!
 * But i’m still hopelessly clueless as to how to get my custom post type to show
   @@ been looking at the code for 2 days now.
    can’t find a clue where is the code
   pointing WP to load post_type=listing to the template it is using. not in index.
   php, not in functions.php, not in header.php, not in single.php. I basically 
   went through most if not all of the .php files and ctrl-f [listing] to find a
   clue. @@ /end rant.
 * thanks^^
 *  Thread Starter [du3z](https://wordpress.org/support/users/du3z/)
 * (@du3z)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp_query-syntax-the-loop/#post-2683277)
 * @ alchymyth, i just used the rewritten array syntax and added array(‘post_type’
   => ‘listing’, ‘post_type’ => ‘project’, … … …
 * and i for the first time in a day and half i saw some real progress, at least
   it is tapping on the latest listings blog-type update on my homepage, and actually
   showing something~ now to figure out why the single post page isn’t showing!
 * -elated- thanks much
 *  Thread Starter [du3z](https://wordpress.org/support/users/du3z/)
 * (@du3z)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp_query-syntax-the-loop/#post-2683280)
 * a moment of eureka!
 * It was as simple as a creating a single-[customposttypename.php]. And there i
   was searching for a ghost file that never existed. I supposed i couldn’t understand
   what the codex meant, until now that is. yay.
 * now i have another problem..but this case here is closed. yay happy.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘WP_Query syntax (The Loop)’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [du3z](https://wordpress.org/support/users/du3z/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/wp_query-syntax-the-loop/#post-2683280)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
