Forums

[resolved] Query Pages Where Custom Field Exists (5 posts)

  1. freshifreshy
    Member
    Posted 8 months ago #

    How want to be able to get an excerpt from pages that only have a certain custom field. How would I write a query to do this?

    Your help is appreciated!

  2. MichaelH
    moderator
    Posted 8 months ago #

  3. Otto42
    Moderator
    Posted 8 months ago #

    meta_key and meta_value are valid query parameters for the WP_Query object in 2.6.2.

    To get all the pages for a given meta key, one could do something like this:
    $myquery = WP_Query('post_type=page&meta_key=MYKEY');

  4. freshifreshy
    Member
    Posted 8 months ago #

    Thanks so much!

  5. arstuavitamea
    Member
    Posted 8 months ago #

    hi from Italy
    how can i wp-query posts for a certain category and order by a certain metakey? eg. surname alphabetically?

Reply

You must log in to post.

About this Topic