Forums

Calling posts tagged with todays date (3 posts)

  1. sugupal
    Member
    Posted 1 year ago #

    Hello,
    I am sort of new to wp and wondering if there is a way to do the following:

    I have a list of posts that represent events.
    I want to tag or classify each post/event with the date of the day they will be happening. but I will be posting them before hand so the post date and the event date are different.
    Then I want to have a code that gets the current "today's" date and calls all the posts tagged or classified with that date "today's" date.
    I know it is quite complicated but if anybody has an idea on how to do this I would really appreciate it.

  2. Edward Caissie
    Member
    Posted 1 year ago #

    Have you looked at "Event Calendar" plugins?

  3. sugupal
    Member
    Posted 1 year ago #

    yes, I did look into calendar plug-ins but I really didn't found exactly what I wanted.
    Besides, right now my site is quite complicated and I want to keep it as simple as possible.
    But the good news is that I am almost there!
    I found a snippet that adds a "Date" custom field and then compares it to todays date and displays the posts that have an equal or greater date, so in other words upcoming events.

    <?php
    // Get today's date in the right format
    $todaysDate = date('m/d/Y');
    query_posts('showposts=10&meta_key=Date&meta_compare=<=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC'); ?>

    The only problem is that I only want to show the posts that have a date equal to today's date. So I tried this (but it is not working):

    <?php
    // Get today's date in the right format
    $todaysDate = date('m/d/Y');
    query_posts('showposts=10&meta_key=Date&meta_compare===&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC'); ?>

    As you might notice I am super new to php and would really appreciate some light to this issue.

Topic Closed

This topic has been closed to new replies.

About this Topic