• Resolved du3z

    (@du3z)


    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.ww.wp.xz.cn/The_Loop

    I’m not sure what the correct syntax, i was reading this:
    http://codex.ww.wp.xz.cn/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)
  • No – you cannot add a WP_Query to the standard $query. The former overwrites the latter.

    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

    (@du3z)

    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

    (@du3z)

    @ 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

    (@du3z)

    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.