How to output most recent post from blog

edited August 2014 in Modules
I've downloaded and installed the blog module from here: https://github.com/daylightstudio/FUEL-CMS-Blog-Module

However, I'm finding it impossible to output the most recent blog post title, date and link on the homepage of my site. I've tried to follow the docs but everything I try just dumps the blogs complete array and kills the page.

This is the code I'm using:

$blogpost = $this->fuel->blog->get_recent_posts(1, array('author_id' => 1)); print_r($blogpost)

What am I doing wrong?

Thanks

Comments

  • edited 12:54AM
    What gets returned is an array of blog posts even though you are limiting it to 1. So you will still need to either loop or do something like $post = current($blogpost);
  • edited 12:54AM
    What is the point in setting a limit then? I still can't get it to work. It seems to be outputting all fuel data. No blog post data to be found in the array. https://www.dropbox.com/s/p9xhsvpmyzi8m4o/Screen Shot 2014-08-05 at 18.56.05.png
  • edited 12:54AM
    The limit value sets the max number of records to return in the array. Does the following code work for you:
    $CI =& get_instance();
    $blogpost = $CI->fuel->blog->get_recent_posts(1, array('author_id' => 1));
    foreach($blogpost as $post) :
    echo $post->title;
    endforeach;
Sign In or Register to comment.