date == $b->date ? 0 : ( $a->date < $b->date ) ? 1 : -1; } // Return blog posts. function get_posts($posts, $page = 1, $perpage = 0){ if(empty($posts)) { $posts = get_post_sorted(); } $tmp = array(); // Extract a specific page with results $posts = array_slice($posts, ($page-1) * $perpage, $perpage); foreach($posts as $index => $v){ $post = new stdClass; $filepath = $v['dirname'] . '/' . $v['basename']; // Extract the date $arr = explode('_', $filepath); // Replaced string $replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/'; // Author string $str = explode('/', $replaced); $author = $str[count($str)-3]; // The post author + author url $post->author = $author; $post->authorurl = site_url() . 'author/' . $author; $dt = str_replace($replaced,'',$arr[0]); $t = str_replace('-', '', $dt); $time = new DateTime($t); $timestamp= $time->format("Y-m-d H:i:s"); // The post date $post->date = strtotime($timestamp); // The archive per day $post->archive = site_url(). 'archive/' . date('Y-m-d', $post->date) ; // The post URL $post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[2]); $tag = array(); $url = array(); $bc = array(); $t = explode(',', $arr[1]); foreach($t as $tt) { $tag[] = array($tt, site_url(). 'tag/' . $tt); } foreach($tag as $a) { $url[] = ''. $a[0] .''; $bc[] = ''. $a[0] .''; } $post->tag = implode(', ', $url); $post->tagb = implode(' ยป ', $bc); $post->file = $filepath; // Get the contents and convert it to HTML $content = MarkdownExtra::defaultTransform(file_get_contents($filepath)); // Extract the title and body $arr = explode('t-->', $content); if(isset($arr[1])) { $title = str_replace('', $content); if(isset($arr[1])) { $title = str_replace('', $content); if(isset($arr[1])) { $title = str_replace('', $content); if(isset($arr[1])) { $title = str_replace('