$nopages = "AND $wpdb->posts.post_type = 'post'";
In addition to the post
post type, I'd like to add a couple more (i.e. 'projects' and 'videos'). I'm not much of a coder so I'm not sure where to begin. Can开发者_StackOverflow中文版 I add something like 'post_type' => array( 'post','videos','projects' ),
anywhere in there?
You'll have to use IN()
in your SQL query :
"AND $wpdb->posts.post_type IN ('post','videos','projects')";
And, if you have those in a PHP array, like this :
$types = array('post','videos','projects');
You can use the implode()
to concatenate them into a string that can be used in an SQL query :
$types_in = implode(', ', $types);
"AND $wpdb->posts.post_type IN ($types_in)";
精彩评论