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 wonder if someone would know how to query specific pages (not by id), lets say I create a custom field called "product", and I would like to query all pages with that custom field.

Any Help?

Kind Regards :)!


So far I've found this solution

thank u so much! so far I've found this solution

 global $wp_query;
 $args = array_merge( $wp_query->query, array( 'post_type' => 'page' , 'meta_key' => 'product' ) );
 query_posts( $args );


and works really cool!

share|improve this question
up vote 2 down vote accepted

As you can see on http://codex.wordpress.org/Function_Reference/get_pages you can query by meta_key , so to query by product custom field, you will do something like this .

    'meta_key' => 'product'
$pages = get_pages( $args );
share|improve this answer
thank u so much! so far I've found this solution! I'm updating the post! – andresmijares25 Sep 27 '11 at 19:17

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.