Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Guido on "Get post meta (date) outside loop"

$
0
0

Hi,

I have a variable called 'today' and I'm using this to list events on date. I have added a custom meta field called 'event-days' to add extra days to variable 'today'.

But it doesn't work.
Note: it's located outside the loop and that's why I call the wp_query for the 'event_days'.

global $wp_query;
$postid = $wp_query->post->ID;
$event_days = get_post_meta( $postid, 'event-days', true );

$now = strtotime('today');
if ($event_days == 'two') {
	$today = strtotime($now . "+1 day");
} else if ($event_days == 'three') {
	$today = strtotime($now . "+2 days");
} else if ($event_days == 'four') {
	$today = strtotime($now . "+3 days");
} else {
	$today = strtotime('today');
}

Suggestions? I think it might has something to do with being outside the loop.

Guido


Viewing all articles
Browse latest Browse all 8245

Trending Articles