• Hi,

    Using the plugin to display recent events with custom post type, works fine all ordered by meta etc. I really need to only display events that have occured before today using custom field ‘event_start’. I gather i can add a hook into my functions.php but cant figure out what it would look like. Any dieas how this can be achevied?

    Thanks in advance!
    Lauren

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Rafa? Gicgier

    (@gicolek)

    Hello sovvyg,

    You will have to do the following:

    1. Widget setup: https://www.screencast.com/t/AIeVzziXMYua (you might need to change meta compare to <)
    2. Place the following hook in the functions.php:

    
    add_filter( 'acf_meta_value', 'my_date_function', 10);
    
    function my_date_function( $meta_value ){
     if( $meta_value == '_my_custom_value' ) {
         // this modifies _my_custom_value string only not affecting all other settings.
         $meta_value = date( "Ymd" );
     }
    return $meta_value;
    }
    

    Note that this only works if you have the date of event_start stored as Ymd.

    Let me know if it helps!

    Cheers,
    Rafal

    Thread Starter sovvyg

    (@sovvyg)

    thanks, the date is stored as Unix TS, any way to convert this to then filter?

    Plugin Author Rafa? Gicgier

    (@gicolek)

    Even if you convert it it won’t work due to the way WordPress handles meta query and date.

    That’s a requirement.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hook to display posts before today using custom date’ is closed to new replies.