• 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter TigerDE2

    (@tigerde2)

    P.S.: the post title should read
    Latest x links from # cats on one page, listed by cats. ??

    Hi T:
    There is a function called previous_post that looks like this:
    previous_post( $format, $linktext, $use_title, $in_same_cat,
    $limitprev, $excluded_categories )
    It doesn’t do exactly what you want, but it might come close
    enough.
    I have draft documentation for the function, but it’s not
    complete, nor has it been tested, so it might be wrong.
    I don’t want to post public links to it, but if you email
    me (my username at my username do tn et) I’ll email
    you a link.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Latest x links from # cats on one page, listed by’ is closed to new replies.