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 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 :)!

UPDATE:

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
add comment

1 Answer 1

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 .

$args=array(
    '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
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.