0

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!

2

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 );
  • thank u so much! so far I've found this solution! I'm updating the post! – andresmijares Sep 27 '11 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.