Latest x links from # cats on one page, listed by
-
Hi!
I’m looking for sth. similar to the following b2 hack:
[?php
function get_latest_post_by_category($cat=1) {
global $tableposts;
$post_amount = “post_content AS content”; // opt.
$post_amount = “SUBSTRING(post_content, 1, 80) AS content”;
$sql= ” SELECT ID, post_title, DATE_FORMAT(post_date, ‘%d.%m.%y – %h:%i’) AS formatted_date, ” .
” $post_amount ” .
” FROM $tableposts ” .
” WHERE post_category = $cat ” .
” ORDER BY post_date DESC LIMIT 1″;
$result=mysql_query($sql);
if ($row = mysql_fetch_array($result)) {
echo(‘<b>’.stripslashes($row[‘post_title’]).'</b> ‘.$row[‘formatted_date’].'[br /]’.
stripslashes($row[‘content’]).’…’);
}
}
?]
It should be a hack to display the last post from the given cat on the page, allowing to have the latest posts (in full) from one or more category/categories.
e.g.:
cat 1:
last post title
latest post
cat 2:
last post title
latest post
A second argument would be cool in order to tell wp how many posts you want.
Anyway: I need this as soon as possible and I’d be totally happy if somebody could help me in achiving this.
[update] I just tried that hack, it works fine with wp.
However, I’d still need the 2nd argument… ?? [/update]
Thanks in advance.
Christian
- The topic ‘Latest x links from # cats on one page, listed by’ is closed to new replies.