The MU forums have moved to WordPress.org

New to MU ,get_last_updated_post()? (4 posts)

  1. jiaJia
    Member
    Posted 16 years ago #

    i am not very familar with php,i want to show the newest posts of all the users,how can i do that?
    get_last_updated() then get_blog_post($blog_id,$post_id)?
    like that?or is there a function like get_last_updated_posts()?
    by the way,where can i find a full templete functions document of wpmu?
    silly questions.
    hope anyone can help.
    thanks.

  2. ehab
    Member
    Posted 16 years ago #

    Not a silly question - I am suffering from the same problems as well. We don't have a detailed Codex for MU yet - only 2 functions are explained -(

    We would have to wait for someone experienced to show us the way

  3. andrea_r
    Moderator
    Posted 16 years ago #

    In the download, in the default home theme that is initially set for you, the code is there. look in wp-content/home/home.php.

    Otherwise, you can go to wpmudev'org/plugins/ and get any one of the most recent posts, or just parse the sitewide feed.

  4. jiaJia
    Member
    Posted 16 years ago #

    Thanks.
    I found this and it works.

    /*
    Plugin Name: WordPress MU Recent Posts
    Plugin URI: http://atypicalhomeschool.net/wordpress-plugins/
    Description: Retrieves a list of the most recent posts in a WordPress MU installation. Based on (Andrea - fill this in)
    Version: 0.3
    Author: Ron Rennick
    Author URI: http://atypicalhomeschool.net/

    */

    function ah_recent_posts_mu($how_many = 10) {
    global $wpdb;
    $counter = 0;
    // get a list of blogs in order of most recent update
    $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE
    last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
    ORDER BY last_updated DESC");

    if ($blogs) {
    foreach ($blogs as $blog) {
    // we need _posts and _options tables for this to work
    $blogOptionsTable = "wp_".$blog."_options";
    $blogPostsTable = "wp_".$blog."_posts";
    $options = $wpdb->get_results("SELECT option_value FROM
    $blogOptionsTable WHERE option_name IN ('siteurl','blogname')
    ORDER BY option_name DESC");
    // we fetch the title and link for the latest post
    $thispost = $wpdb->get_results("SELECT post_title, guid
    FROM $blogPostsTable WHERE post_status = 'publish'
    AND post_type = 'post' AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
    ORDER BY id DESC LIMIT 0,1");
    // if it is found put it to the output
    if($thispost) {
    echo '<li class="page_item">guid
    .'">'.$thispost[0]->post_title.'
    by <a href="'
    .$options[0]->option_value.'">'
    .$options[1]->option_value."

  5. ";
    $counter++;
    }
    // don't go over the limit
    if($counter >= $how_many) {
    break;
    }
    }
    }
    }

    another question,is wp-includes/wpmu-functions.php a right place to put some functions you designed for your MU? or wp-content/themes/exampleTheme/functions.php?

About this Topic