WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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(
            'key' => 'app_visibility',
            'value' => 1,
            'compare' => '='



$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!

share|improve this question
up vote 5 down vote accepted
'post_type' => 'custom post type slug'

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:


share|improve this answer
This worked great thank you. Just added 'post_type' => 'on-road' and it pulled it in :-) – Joshc Nov 20 '12 at 18:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.