WordPress.org

Ready to get started?Download WordPress

Forums

Get Posts by Custom Fields? (1 post)

  1. jayp
    Member
    Posted 8 years ago #

    Is there a way to select posts based on a custom field?

    For example, if I'm doing something like this:

    $posts = get_posts('numberposts=1');

    can I do something like this?

    $posts = get_posts('numberposts=1&customfield=x');

    I looked at the get_posts() function and the query_posts() function.

    What I want to do is add a custom field to one post called "featured", set it to 1 on the desired post, and then be able to highlight that post on the hompage.

    I also want to be able to select the 9 most recent posts that do not have featured set to 1.

    Am I asking the impossible?

Topic Closed

This topic has been closed to new replies.

About this Topic