Can't get the value of an php array key to display
Hello I am working on a wordpress theme and whan't a function to return
the information of the last published post. my function so far:
function get_last_post()
{
$latest_post = new
WP_Query("post_type=post&posts_per_page=1&orderby=date&order=DESC&post_status=publish");
if($latest_post->have_posts())
{
reset($latest_post);
$cur = current($latest_post);
var_dump($cur);
//var_dump($cur['']);
$ret['title'] = $cur['post_title'];
$ret['content'] = $cur['post_content'];;
$ret['link'] = get_permalink($cur['ID']);
}
else {
$ret['title'] = _e('Ni objav', 'responsive');
$ret['content'] = _e('ni novih objav', 'responsive');
$ret['link'] = '';
}
return $ret;
}
The problem is that I can't get the information from the array. I know
total newbish but bare with me I am relatively new to php and I don't do
it often.
if I var_dump the array var_dump($cur); the information I whan't is there
but can't seem to be able to grab it if I do var_dump($cur['post_title'])
it returns NULL also I didn't find anything usefull on this on the web.
Hope you guys can help.
No comments:
Post a Comment