Take the 2-minute tour ×  I have the following code which gives
be posts that are published in the last 100 days  function
smbd_cats_by_days ($where = '') {      $where .= " AND post_date
< '" . date('y-m-d', strtotime("-100 days")) . "'";     return
$where;  add_filter('posts_where', 'smbd_cats_by_days');  It is
working fine. But now I want to make this function generic. (ie)
I want the number of days to be stored in a variable instead of
hard coding it as 100.  How to do that?  share|improve this
question How do you want to set the variable? Not technically,
programmer-y "how", but human "how"? Is this a theme option? Do
you want to pass a parameter when you add the filter? Set a
constant? What? –  s_ha_dum Dec 8 '12 at 16:40 I want to pass it
as a parameter when I add the filter. –  Sudar Dec 8 '12 at
16:41 Duplicate of Custom time range for the posts_where filter
–  Milo Oct 17 '13 at 18:06 add comment  2 Answers  up vote 1
down vote accepted  I was afraid you wanted that one. You can't
really do that. Fo