Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

1 Answer

up vote 3 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:

http://codex.wordpress.org/Class_Reference/WP_Query

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

Your Answer

 
discard

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.