WordPress.org

Ready to get started?Download WordPress

Forums

Using Custom Fields INSIDE Query Posts command (5 posts)

  1. drexp2000
    Member
    Posted 4 years ago #

    I've been searching everywhere and asked a few WordPress masterminds, but everyone seemed to be stomped with this request. Hopefully you guys can help me with this.

    I would like to use the data in a custom field to query certain posts in my custom page.

    For example, in query_posts(array('category__and' => array(2,6)));

    That queries posts that are BOTH in categories 2 and 6. Is there a way to replace the 2,6 with a custom field?

    Like:
    query_posts(array('category__and' => array(CUSTOMFIELD1DATA,CUSTOMFIELD2DATA)));

    Is that doable? I need something like this due to a complex list of categories I have and I really don't want to make 15 different custom pages.

    Please advise and thank you in advance.

    -Andre

  2. Darrell Schauss
    Member
    Posted 4 years ago #

    The custom field parameters for query_posts are here..
    http://codex.wordpress.org/Function_Reference/query_posts#Custom_Field_Parameters

  3. drexp2000
    Member
    Posted 4 years ago #

    Thanks for the reply, Darrell. I understand the custom field parameters and how they work. But what I'm trying to do is to do a custom query using the category ID # in the custom field value. So when I create a custom page, I can make each page have a dynamic query posting, thus not needing to create multiple custom query pages.

    -Andre

  4. adam533
    Member
    Posted 4 years ago #

    Not sure if you ever found a solution but I am looking for the exact same thing.

  5. vtxyzzy
    Member
    Posted 4 years ago #

    See the answer I posted to Adam533. Take a look at my BlueGrassMiataClub.com site. The pages under 'Good Stuff', 'Event Talk', 'For Sale', etc all use a single template.

Topic Closed

This topic has been closed to new replies.

About this Topic