WordPress.org

Ready to get started?Download WordPress

Forums

Filtering posts after category and a meta value (3 posts)

  1. MeeCom
    Member
    Posted 3 years ago #

    Hello,

    currently I have a little problem with filtering my posts in a widget. I need to filter my posts after a category id and a meta_key. The thingy with the meta_value wasn't the problem but how can I select the categories then?

    The following SQL query is the current status:

    SELECT post.*, meta.meta_value AS release_date
    FROM $wpdb->posts post
    INNER JOIN $wpdb->postmeta meta ON post.id = meta.post_id
    AND meta.meta_key = 'date'

    Maybe one of you can give me a last tip :)

    Thanks in advance!

  2. MeeCom
    Member
    Posted 3 years ago #

    Does anybody has an idea?

  3. cebradesign
    Member
    Posted 3 years ago #

    I guess you need to pass along the meta value also.

    SELECT post.*, meta.meta_value AS release_date
    FROM $wpdb->posts post
    INNER JOIN $wpdb->postmeta meta ON post.id = meta.post_id
    AND meta.meta_key = 'date'
    AND meta.meta_value = '09/09/2010'

    Didn't test it so I don't know if it works.

    Cheers!

Topic Closed

This topic has been closed to new replies.

About this Topic