WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. freshifreshy
    Member
    Posted 5 years 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
    Member
    Posted 5 years ago #

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years 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 5 years ago #

    Thanks so much!

  5. arstuavitamea
    Member
    Posted 5 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic