I've tried to change this code:
function filter_where( $where = '' ) {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-365 days')) . "'";
return $where;}
add_filter( 'posts_where', 'filter_where' );
into this one:
function filter_where( $where = '' ) {
$where .= " AND post_date > '" . date('Y-m-d', strto开发者_高级运维time('-'.$timestamp.' days')) ."'";
return $where;}
add_filter( 'posts_where', 'filter_where' );
You may noticed that I've tried to put variable $timestamp inside strtotime. However the code doesn't work. Did I do the correct syntax to put the variable within the strtotime PHP function?
I appreciate any kind of help.
It is the correct code if $timestamp
contains a positive integer.
However, in the context of that function and without the global
keyword, $timestamp
is undefined and null
.
Do you mean to pass that variable as an argument of and_where()
?
精彩评论