The MU forums have moved to WordPress.org

List-All Plugin (Modified) (17 posts)

  1. kiwizz
    Member
    Posted 18 years ago #

    Im looking for some help in displaying the most active blog on my domain (blogger-off.com) and would like to know if its possible (it may already exist) for someone to modify the list-all plugin so it retrieves the most active blog (url, blog name, etc)

    Also, If there was another plugin to retrieve the most recent post with similar features.

    Thanks!

  2. andrewbillits
    Member
    Posted 18 years ago #

    I'm the one behind that little plugin. I'm surprised at how popular it is. You might want to check out the Fimii WPMU Stats plugin as I think it does what you want. :)

  3. kiwizz
    Member
    Posted 18 years ago #

    thanks for the reply andrew, but the other plugins only show get_last_updated and get_newest_blog. I haven found any that are able to show the most active blog.

    I initially was modifying the wpmu_functions.php and calling the inbuilt get_most_active (or whatever it was) but I was unable to get it to produce the name of the blog (was something like $details[ 'domain' ] - i tried other stuff like name, username user_name login, etc)

  4. kiwizz
    Member
    Posted 18 years ago #

    anyone have any other suggestions?

  5. samchng
    Member
    Posted 18 years ago #

    Could it be blog_id? I use that to pull blogs out from db for Latest Updated Blog.

  6. kiwizz
    Member
    Posted 18 years ago #

    i did try both $blog_id and $details[ 'blog_id' ] and neither workeed, yet I think it brought up the blog id number. If there was a way to get php to retrieve the name of the blog based on that id number, then it could be a work around.

    Anyone know how to do this?

    Thanks.

  7. andrewbillits
    Member
    Posted 18 years ago #

    kiwizz, if you have the blog id then all you have to do is write a db query to retrieve the name of the blog. Something like:

    $name = $wpdb->get_row("SELECT option_value FROM " . $blog_id . "_options WHERE option_name = 'blogname' LIMIT 1");

    Now that's just an example, i can't even recall exactly where the blog name is stored but that snippet will atleast get you going in the right direction.

  8. kiwizz
    Member
    Posted 18 years ago #

    Thanks for that, but I am unable to understand enough to get it going. The blog.id's table does not have the blog name in it, as the name is stored in the users table. Any other suggestions?

  9. villagepine
    Member
    Posted 18 years ago #

    Any solutions out there yet for this?

    RECAP: I can successfully display "Most Recent Blogs" and "Most Recent Posts", but I cannot figure out a way to display the "Most Active Posts" (a.k.a. "Most Read Posts", "Most Popular Posts", etc.).

  10. debrouille
    Member
    Posted 18 years ago #

    I'm working on similar functions. I need things like 'last posts', 'blogs with newest posts', 'most read blogs' etc...

    I'll write here when i come further.

    How do you get the "Most Recent Blogs" and "Most Recent Posts"?

  11. villagepine
    Member
    Posted 18 years ago #

    I have found solutions to "Most Recent Blogs" and "Most Recent Posts" elsewhere in these forums ... so I am not taking credit for this code, in anyway, but this is the code I use.

    For "Most Recent Posts":

    - - - - - - - - - - - - - - - - - -

    <div class="recent-posts">
    <h2>Recent Posts</h2>
    <?php
    $blogs = get_last_updated();
    foreach ($blogs as $blog) :
    // we need _posts and _options tables for this to work
    $blogOptionsTable = "wp_".$blog['blog_id']."_options";
    $blogPostsTable = "wp_".$blog['blog_id']."_posts";

    // we fetch the blog name
    $opt2 = $wpdb->get_col("SELECT option_value FROM $blogOptionsTable WHERE option_name='blogname'");

    // we fetch the latest post
    $opt3 = $wpdb->get_row("SELECT * FROM $blogPostsTable WHERE post_status='publish' AND post_type='post' ORDER BY post_date DESC LIMIT 0,1");

    // sometimes the guid is missing, so just use blog url
    if (trim($opt3->guid)) {
    $mypostlink = trim($opt3->guid);
    } else {
    $mypostlink = 'http://'.trim($blog['domain']);
    }

    $myposttitle = '<big><a href="'.$mypostlink.'"><b>'.$opt3->post_title.'</b></a></big><br/>';
    $mypostdetails = '<small>from <a href="http://'.trim($blog['domain']).'">'.trim($blog['domain']).'</a> on '.strftime("%A, %B %d, %Y at %I:%M %p",strtotime($opt3->post_date)).'</small><br/>';
    $mypostcontent = '<em>'.$opt3->post_content.'</em>';

    print '<div class="post">'."n".$myposttitle."n".$mypostdetails."n".$mypostcontent."n</div>n";

    endforeach;
    ?>
    </div>

    - - - - - - - - - - - - - - - - - -

  12. villagepine
    Member
    Posted 18 years ago #

    Oh yeah, and I can't find the code for "Most Recent Blogs", but here is the code for the complete Blog List. Again this is not my "original" code, I found it here on these forums.

    - - - - - - - - - - - - - - - - - -

    <div id="blog-list">
    <h2>Blogs</h2>
    <?php
    // this function is in wp-includes/wpmu-functions.php
    // get the array of blogs
    $blogs = get_blog_list(0, 'all');
    foreach ($blogs as $blog) :
    // This is the table to get the blogname
    $tblog = "wp_".$blog['blog_id']."_options";
    $blogname = $wpdb->get_col("SELECT option_value FROM $tblog WHERE option_name='blogname'");
    // print one line each blog with: blogurl - blogname [num posts]
    print '<a href="http://'.$blog['domain'].'">'.$blog['domain'].'</a> - '.ucfirst($blogname[0]).' <small>['.$blog['postcount'].' posts]</small><br/>'."n";
    endforeach;
    ?>
    </div>

    - - - - - - - - - - - - - - - - - -

    I'll see if I can find the code for the "Most Recent Blogs" and then I'll post it here ... but I think it is nothing more than a derivative of the above code.

  13. anothero
    Member
    Posted 18 years ago #

    The code for Most recent posts is great, just wondering if I could use the plugin the_excerpt Reloaded, I don't want the whole post on my home page, just first 25 words or something.

  14. mshao
    Member
    Posted 18 years ago #


  15. zappoman
    Member
    Posted 17 years ago #

    I was looking for a "top posts" solution, couldn't find one, so I've hacked on this idea a little bit, and put together a simple prototype of "top posts"... you can find the first cut at it here...

    http://heftagaub.wordpress.com/2007/03/11/wpmu-top-posts-plugin/

    The page doesn't contain a lot of documentation yet, but the code has more than enough.

    This is very early, I'm sure it could be optimized, I haven't tested it that much but it seems to be working in my test environment.

    I tried to make it work like get_posts() and I also added some template style functions... like get_the_title() and the_title().

    I don't know if there is a better version of this out there, but for now, here's a cut at what I was thinking.

  16. softlord
    Member
    Posted 16 years ago #

    This code is great. I'm trying to add post author to it, and it doesn't seem to be working. The code i have is:

    $blogUsersTable = "wp_users";
    // we fetch the author
    $opt4 = $wpdb->get_results("SELECT ID, user_nicename FROM $blogusersTable");
    $mypostdetails = '<div class="postmeta">Posted by '.$opt4->post_author.' from '.ucfirst($opt2[0]).' on '.strftime("%A, %B %d, %Y at %I:%M %p",strtotime($opt3->post_date)).'</div><br/>';

  17. dsader
    Member
    Posted 16 years ago #

    Here's an author snip added to working ah_recent_posts_mu(http://wpmudevorg.wordpress.com/project/Most-recent-posts---updated) for comparison:

    $tmp_post_author_id = $thispost[0]->post_author;
    $tmp_post_author = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE ID = '" . $tmp_post_author_id . "'");

    and later
    Posted by <?php $tmp_post_author; ?>

About this Topic