WordPress.org

Forums

How to get posts by more than one custom field? (1 post)

  1. ovidiuionita
    Member
    Posted 3 years ago #

    Hi!
    I`m building a wordpress theme for a website which will actually feature two website. One for a radio station and one for an online newspaper.
    On the frontpage I want to display certain important posts, based on one or two custom fields.
    I`m using the query_posts() function to display articles filtered by only one custom field.

    <?php query_posts('meta_key=field-name&meta_value=field-value'); ?>

    But my problem is that this method only accepts one custom field as a filter. I have a few sections where I need to filter articles by two custom fields.
    How can I achieve this?
    Do I need to add a new function to my theme`s functions.php file, or directly from the loop?

    [ Please do not bump, it's not permitted here. ]

Topic Closed

This topic has been closed to new replies.

About this Topic