0

I have a Custom Post Type using the Custom Post Type UI plugin called Case Studies. I'm also using the Custom Fields to add a capability field to the Case Studies.

How can I query Case Studies where the capability is equal to some ID?

$query = array('post_type' => 'case-studies','posts_per_page' => 3);

is my query so far

2 Answers 2

3

It could be

$query = array(
    'post_type' => 'case-studies',
    'meta_key' => 'capability',
    'meta_value' => 10, // some ID
    'posts_per_page' => 3
);

$the_query = new WP_Query( $query );
while ( $the_query->have_posts() ) : $the_query->the_post();
    // echo here
endwhile;
wp_reset_postdata();
Sign up to request clarification or add additional context in comments.

Comments

0

You need to set your key to capability, and then query value by your post ID.

'meta_query' => array(
  array(
    'key' => 'capability',
    'value' => $post->ID,
    'compare' => 'example'
  )
)

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.