• using this filter

    add_filter( 'posts_where', 'filter_where' );
    
    $thisdate = the_date(Y-m-d,'','',false);
    
    function filter_where($where = '') {
    	$thisdate = the_date(Y-m-d,'','',false);
        $where .= " AND post_date >= '$thisdate'";
        return $where;
    }

    while in a loop of a post….how can i pass the variable $thisdate into the function?

    i tried setting $thisdate to global…no luck…im stumped i dont really understand

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Filter hook functions only get what the originating apply_filters() function decides to pass to it, you can’t add extra parameters.

    Not sure why the global approach didn’t work for you.

    Thread Starter phillymantis

    (@phillymantis)

    the global approach WORKED

    i was just a dumb ass and used it outside the function instead of within

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to pass current post id…into function for filter’ is closed to new replies.