Custom WordPress query using WP_Query()

I’m trying to get a custom query going in wordpress.
Basically, I want to select all custom post types where the variable “name” has been set to “sean”.

I have tried the following :

Read More
$my_loop = new WP_Query( array( 'post_type' => 'my_post', 'meta_value=sean',
'posts_per_page' => 15, 'orderby' => 'id', 'order' => 'DESC' ) );

I got this from the wordpress codex :
Display posts where the custom field value is ‘blue’, regardless of the custom field key:

$query = new WP_Query( 'meta_value=blue' );

Any Help would be appreciated

EDIT: I should add that I do indeed have a wordpress loop using :

   while ( $my_loop->have_posts() ) {
   $pdf_loop->the_post();.... etc

Thanks again,

Dave

Related posts

Leave a Reply

1 comment

  1. You are mixing query string and array style arguments. Try either

    new WP_Query(array(
        'post_type' => 'my_post', 
        'meta_value' => 'sean',
        'posts_per_page' => 15,
        'orderby' => 'id',
        'order' => 'DESC'
    ));
    

    Or

    new WP_Query('post_type=my_post&meta_value=sean&posts_per_page=15&orderby=id&order=DESC');