I am running a simple wp query to retrieve just one post.
But the post is a custom post-type post, not a normal post
$ajaxBike = $_GET['varbike'];
$bikeProfile = new WP_Query(array(
'name' => $ajaxBike,
'meta_query' => array(
array(
'key' => 'app_visibility',
'value' => 1,
'compare' => '='
)
)
));
or…
$ajaxBike = $_GET['varbike'];
$bikeProfile = new WP_Query('name='.$ajaxBike);
But I think the name parameter only works for posts. But I’m struggling to find anything to work with a custom post type slug.
Can you anyone help work out how to query a custom post type using the slug?
Thanks in advance!
By default ‘post_type’ is set as ‘post’, you will need to specify your custom post type in any query you make.
In future refer here:
http://codex.wordpress.org/Class_Reference/WP_Query