I have the following method in a CI model:
function getPostTitle($post_slug)
{
global $post;
$posts = new WP_Query('name=' . $post_slug);
while ( $posts->have_posts() )
{
$posts->the_post();
return $post->post_name;
}
}
The returned variable is empty. Note that the same code works fine in a view. I need to be able to use the above query in a model so that is available to the controller. Any Wordpress/Codeigniter experts?