1

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 :

$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

1 Answer 1

2

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');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.