Variable in WP-Query
-
Hi guys,
I’m trying to pull back a date range of posts. One of the dates in the range is the current date which I am determining using the PHP date function and assigning to a variable called $today.
If I run this with the date’s hardcoded into the script, it returns the posts I want. If however I try and incorporate the variable it doesn’t work. I’ve tried surrounding the variable in double quotes as I’ve seen suggested elsewhere but it falls over.
Anyone point me in the direction of the correct syntax for the code below:-
function filter_where($where = '') { $where .= " AND post_date >= '1970-01-01' AND post_date <= '$today'"; return $where; }
Thanks in advance.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Variable in WP-Query’ is closed to new replies.