/** * @param $post_id * @param $post_cat * @return null|string */ function get_previous_post($post_id, $post_cat) { $where["cat_id"] = $post_cat[0]["cat_id"]; $where["post_id"] = array('lt', $post_id); $next_post_id = D('Post_cat')->field('post_id')->where($where)->find(); $post = D('Posts', 'Logic')->detail($next_post_id["post_id"], false); if (!$post) { return null; } $res = '<a href = "' . getSingleURLByID($post['post_id'], $post['post_type']) . '">' . is_top($post['post_top']) . $post['post_title'] . '</a>'; return $res; }
<div class="date"> <span class="month"><?php echo gettimestamp($post["post_date"], 'month'); ?> 月</span> <span class="day"><?php echo gettimestamp($post["post_date"], 'day'); ?> 日</span> </div> </div> <div class="media-body"> <a href="<?php echo get_post_url($post); ?> "> <h5><?php echo is_top($post["post_top"]); echo $post["post_title"]; ?> </h5></a> </div> </div><?php } } } ?> </div> </div> <!-- End Popular Posts -->