WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Query Posts Meta Compare by Variable (3 posts)

  1. wesbos
    Member
    Posted 4 years ago #

    Hey guys, I'm trying to use wordpress' Meta value feature. I want to display posts that are greater than a variable that I define via PHP.

    The site displays posts that are ordered by event date (100209 for example) and I want to make sure they are in the future (IE >= $currentdate )

    Any idea how I can pass a variable into this?

  2. wesbos
    Member
    Posted 4 years ago #

    Oh Here is my code

    query_posts('&orderby=meta_value&meta_key=eventdate&order=ASC&meta_compare=>=$currentdate' );

  3. yankeyhotel
    Member
    Posted 4 years ago #

    don't forget to specify the meta_value for the compare. it should look like this.

    query_posts('&orderby=meta_value&meta_key=eventdate&order=ASC&meta_compare=>=&meta_value=$currentdate');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.