Get page permalink and title outside the loop in wordpress
- by Aakash Chakravarthy
Hello,
How to Get page permalink and title outside the loop in wordpress.
I have a function like
function get_post_info(){
$post;
$permalink = get_permalink($post->ID);
$title = get_the_title($post->ID);
return $post_info('url' => $permalink, 'title' => $title);
}
when this function called within the loop, it returns the post's title and url.
When it is called outside the loop. It is not returning the current page's title and url. When called in home page it should return the home page's title and url
How to get like this ? instead this function returns the latest posts title and url