The MU forums have moved to WordPress.org

WPMu Master Feed for front page? (22 posts)

  1. billdennis5
    Member
    Posted 15 years ago #

    Instead of having a front page that just lists my posts to blogpeoria.com, I'd like to use the front page to display ALL posts to ALL blogpeoria.com blogs. I'm using my site's WPMu Master Feed on the sidebar. But I'd like the front page to be an entry point for all blogs in the network. I want readers to be able to go to blogpeoria.com and see the most recent posts.

    I tried to find something about this in the codex, but if there is, I missed it.

    I'm trying to position my site as a network of citizen journalism sites. If you are going to blog in Peoria, I want you to blog via Blog Peoria.

  2. billdennis5
    Member
    Posted 15 years ago #

    To explain further, I simply want to scrape my OWN wpmu-feed to create posts from ALL my WPMu site members to run at the root blog, sending readers to these sites and promote their readership.

  3. dgilmour
    Member
    Posted 15 years ago #

    There are plugins which claim to do this, such as wp-o-matic.

  4. andrea_r
    Moderator
    Posted 15 years ago #

    no no no = he doesn't need wp-o-matic.

    Get the sitewide feed plugin.

    Parse that feed to display on your front page. Your home theme is locked just for the main blog right? And probably has a home.php? Well at any rate, just grab the dashboard feed code out of index-extra, plunk it in your main theme, and change the feed address to your new sitewide feed.

    http://wpmudevorg.wordpress.com/project/WPMU-Sitewide-Feed-Plugin---ITDamager

  5. billdennis5
    Member
    Posted 15 years ago #

    THANK YOU!!!!

    I'll try it when I get a day to do it and handle any goof-ups on my part.

    Andrea rocks.

  6. billdennis5
    Member
    Posted 15 years ago #

    ... and will this let me display the title of the blog, the name of the author? I am doing to to promote the content of my member blogs.

  7. bwinn
    Member
    Posted 15 years ago #

    is there anyway to do this with multiple specific feeds?

  8. billdennis5
    Member
    Posted 15 years ago #

    I imagine I can create a template that displays the sitewise feed, then point my fromt page to this feed.

    Right?

  9. tdjcbe
    Member
    Posted 15 years ago #

    is there anyway to do this with multiple specific feeds?

    You could always put the feeds you want into a dummy Google Reader account and pull from that.

    I imagine I can create a template that displays the sitewise feed, then point my fromt page to this feed.

    Why not take a look at the RSS widget as an example and use code from that directly in your front page file?

  10. andrea_r
    Moderator
    Posted 15 years ago #

    @bill - yeah you could do it that way or plunk the code right on the front page if you wanted. It depends. :)

    @bwinn - you could create a mashup feed eithe r the google reader or yahoo pipes way and use the same code as above to display it, or just repeat that code for each theme.

  11. bwinn
    Member
    Posted 15 years ago #

    I would much rather use this method than Autoblog... Would you suggest this method over autoblog Andrea? Maybe you could do a tutorial on your site?

  12. andrea_r
    Moderator
    Posted 15 years ago #

    It depends on the resutls you ultimately want, I guess. although it;d probably owrk if you wanted to replace the main blog posts, or just have a section of all sitewide posts, or a few select posts.

    more than one way to skin a cat. :D

  13. BondageRadio
    Member
    Posted 15 years ago #

    @ billdennis5 - Good luck with your site, it sounds like a winning idea.

    I've done something similar with my adult WPMU site though, not for the same reason. wpmudev.org is a very good resource and you should have few problems finding the tools you need.

    @ dgilmour - I found wp-o-matic to be a little heavy for my tastes and my site... I went with the trimmer FeedWordPress plugin.

    @ andrea_r - more than one way?... really?... yea, I guess so... I can think of five off the top of my head... here kitty, kitty, kitty...

  14. deanm
    Member
    Posted 15 years ago #

    The sitewide feed plugin looks great. However when I install it, it warns that it's going to slow everything down and recommends WP Object Cache as a solution.

    Does it slow your site down? (I haven't noticed it yet.) Does WP Object Cache speed things up? Would you recommend it? Which plug-in folder would you put it in?

  15. billdennis5
    Member
    Posted 15 years ago #

    Andrea: I am testing your suggestion. I've created a test blog and am running the four-column Kubrick theme. I hacked the index.php page in the theme to replace the loop with what I think is the code to display the wpmu ite feed. I am getting the following error message:

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

    Warning: array_slice() [function.array-slice]: The first argument should be an array in /home/blogpeo1/public_html/wp-content/themes/four-columns-kubrick-10/index.php on line 27

    Warning: Invalid argument supplied for foreach() in /home/blogpeo1/public_html/wp-content/themes/four-columns-kubrick-10/index.php on line 28

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

    I'm attaching the new code for index.php. Maybe you cna tell me what I;m missing or doing wrong:

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

    <?php get_header(); ?>

    <div id="content" class="narrowcolumn">

    <h2>Join The Blog Peoria Project</h2>
    Peoria-area residents can get a Blog Peoria Blog! It's free, and it's better than Blog*Spot because you are part of Peoria's growing community of bloggers.

    <h2>Keep Blog Peoria open (and free to use)</h2>
    Friends can make an anonymous donation <i>directly</i> to The Blog Peoria Project account.

    <h3>Current members</h3>

      <?php list_all_wpmu_blogs('50', 'name', '<p>', '</p>', 'updated') ?>

    <h3><?php _e('Today on Blog Peoria:'); ?></h3>

    </div>

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

  16. dsader
    Member
    Posted 15 years ago #

    Where's $url? $rss?
    example:

    $url = html_entity_decode('http://feed goes here');
    $rss = fetch_rss($url);
  17. billdennis5
    Member
    Posted 15 years ago #

    dsader: I copied and pasted this from index-extra.php (from wp-admin folder) as Andrea suggested. I'm just not sure exactly what parts of this code I'm supposed to copy and pluck into this theme's index.php file.

  18. andrea_r
    Moderator
    Posted 15 years ago #

    This'll help:
    http://blue-anvil.com/archives/wordpress-development-techniques-2-fetching-rss-feeds-with-wordpress

    Also, when pasting code int he forum, don't plunk in large bits, instead link to a text file. For small bits, put the code between backticks (uper left on your keyboard) or the code will get run and look like the above. :)

  19. bwinn
    Member
    Posted 15 years ago #

    None of these options are working for me.

  20. jasonkuter
    Member
    Posted 15 years ago #

    I have no place to link this, but here is the code we use to accomplish this which was developed by someone within my company (and some other stuff). Hope that helps.


    <?php
    /*
    Plugin Name: Feedbag
    Description: Creates a condensed view of recent posts from all blogs.
    Author: Steven L. Eddins
    */

    function wpmu_feedbag_get_blogs() {

    global $wpdb, $wpmuBaseTablePrefix;

    $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs
    WHERE public = '1' AND archived = '0' AND
    last_updated != '0000-00-00 00:00:00' ");

    return($blogs);
    }

    function wpmu_feedbag_get_post_ids() {

    global $wpdb, $wpmuBaseTablePrefix;

    $post_limit_per_blog = 100;
    $blogs = wpmu_feedbag_get_blogs();

    foreach ($blogs as $blogid) {
    $results = $wpdb->get_results("SELECT ID,post_date_gmt
    FROM ".$wpmuBaseTablePrefix.$blogid."_posts
    WHERE post_status = 'publish' AND
    (post_type = 'post' OR post_type = '')
    AND post_date_gmt < '".gmdate("Y-m-d H:i:s")."'
    ORDER BY post_date_gmt DESC LIMIT ". $post_limit_per_blog);

    foreach ($results as $result) {
    $map[] = array($blogid,$result->ID,$result->post_date_gmt);
    $ID[] = $result->ID;
    $date_gmt[] = $result->post_date_gmt;
    }

    }

    array_multisort($date_gmt, SORT_DESC, $ID, SORT_ASC, $map);
    return($map);
    }

    function wpmu_feedbag_get_post_info($max_posts) {

    global $wpdb, $wpmuBaseTablePrefix;

    $untitled = "Untitled";

    $post_ids = wpmu_feedbag_get_post_ids();

    $counter = 0;
    foreach ($post_ids as $post_id) {

    $row = $wpdb->get_row(
    "SELECT * FROM ".$wpmuBaseTablePrefix.intval($post_id[0])."_posts
    WHERE ID = '".intval($post_id[1])."'");

    if ($row->ID) {
    if (!$row->post_title) {
    $row->post_title = $untitled;
    }
    $row->blogid = intval($post_id[0]);
    $rows[] = $row;

    $counter++;
    if ($counter >= $max_posts) {
    break;
    }
    }
    }

    return($rows);
    }

    function wpmu_feedbag_get_comment_ids() {

    global $wpdb, $wpmuBaseTablePrefix;

    $limit = 500;
    $blogs = wpmu_feedbag_get_blogs();

    foreach ($blogs as $blogid) {
    $results = $wpdb->get_results("SELECT comment_ID, comment_date_gmt, comment_post_ID,
    ".$wpmuBaseTablePrefix.$blogid."_posts.ID, ".$wpmuBaseTablePrefix.$blogid."_posts.post_password
    FROM ".$wpmuBaseTablePrefix.$blogid."_comments
    LEFT JOIN ".$wpmuBaseTablePrefix.$blogid."_posts ON comment_post_id = id
    WHERE ".$wpmuBaseTablePrefix.$blogid."_posts.post_status IN ('publish', 'static', 'object')
    AND ".$wpmuBaseTablePrefix.$blogid."_comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "'
    ORDER BY comment_date_gmt DESC LIMIT " . $limit);

    foreach ($results as $result) {
    $map[] = array($blogid,$result->comment_ID,$result->comment_date_gmt);
    $ID[] = $result->comment_ID;
    $date_gmt[] = $result->comment_date_gmt;
    }

    }

    array_multisort($date_gmt, SORT_DESC, $ID, SORT_ASC, $map);
    return($map);
    }

    function wpmu_feedbag_get_comment_info($max_comments) {

    global $wpdb, $wpmuBaseTablePrefix;

    $comment_ids = wpmu_feedbag_get_comment_ids();

    $counter = 0;
    foreach ($comment_ids as $comment_id) {
    $row = $wpdb->get_row("SELECT * FROM `" .
    $wpmuBaseTablePrefix.intval($comment_id[0]) .
    "_commentsWHEREcomment_ID` = '" .
    intval($comment_id[1])."'");

    if ($row->comment_ID) {
    $row->blogid = intval($comment_id[0]);
    $row->comment_gmt_date = $comment_id[2];
    $rows[] = $row;
    }

    $counter++;
    if ($counter >= $max_comments) {
    break;
    }
    }

    return($rows);
    }

    function wpmu_feedbag_condense_content_string($content, $max_words) {
    $content = strip_tags($content);

    $content = str_replace(array("\r\n", "\n", "\r"), " ", $content);

    $content = explode(' ', $content);
    for ($i = 0; $i < $max_words; $i++) {
    $summary[$i] = $content[$i];
    }
    $summary = implode(' ', $summary) . '...';

    return($summary);
    }

    function wpmu_feedbag_elapsed_time($date_gmt) {
    $elapsed_time = strtotime(gmdate("Y-m-d H:i:s")) -
    strtotime($date_gmt);

    return($elapsed_time);
    }

    function wpmu_feedbag_ago_string($time_ago) {

    if ($time_ago < 60) {
    $str = "seconds ago";

    } else if ($time_ago < 120) {
    $str = "1 minute ago";

    } else if ($time_ago < 3600) {
    $str = strval(floor($time_ago / 60)) . " minutes ago";

    } else if ($time_ago < 7200) {
    $str = strval("1 hour ago");

    } else if ($time_ago < 86400) {
    $str = strval(floor($time_ago / 3600)) . " hours ago";

    } else if ($time_ago < 172800) {
    $str = "yesterday";

    } else {
    $str = strval(floor($time_ago / 86400)) . " days ago";
    }

    return($str);
    }

    function wpmu_feedbag_recent_posts_condensed($max_posts) {

    global $wpdb, $wpmuBaseTablePrefix;

    $post_info = wpmu_feedbag_get_post_info($max_posts);

    foreach ($post_info as $post) {
    $blog_name = $wpdb->get_var("SELECT option_value FROM " .
    $wpmuBaseTablePrefix . $post->blogid . "_options" .
    " WHERE option_name = 'blogname'");

    $blog_url = $wpdb->get_var("SELECT option_value FROM " .
    $wpmuBaseTablePrefix . $post->blogid . "_options" .
    " WHERE option_name = 'siteurl'");

    $post_author_name = get_author_name($post->post_author);

    print "<p style=\"margin-bottom: 0;\"> ";
    print "guid\">";
    print $post->post_title;
    print "
    ";
    print "
    </p>";

    print "<p style=\"padding-left: 2em; margin-top: 0;\">";
    $summary = wpmu_feedbag_condense_content_string($post->post_content, 25);
    print "$summary\n";

    print "";
    $time_ago = wpmu_feedbag_elapsed_time($post->post_date_gmt);
    $time_ago_str = wpmu_feedbag_ago_string($time_ago);
    print "
    Posted $time_ago_str";

    print " on $blog_name";

    print " by $post_author_name\n";

    if ($post->comment_count > 0) {
    if ($post->comment_count == 1) {
    print "
    1 comment\n";
    } else {
    print "
    $post->comment_count comments\n";
    }
    }

    print "\n";

    print "</p>\n";
    }

    }

    function wpmu_feedbag_recent_comments($max_comments) {

    global $wpdb, $wpmuBaseTablePrefix;

    $comment_info = wpmu_feedbag_get_comment_info($max_comments);

    foreach ($comment_info as $comment) {
    $blog_name = $wpdb->get_var("SELECT option_value FROM " .
    $wpmuBaseTablePrefix . intval($comment->blogid) . "_options" .
    " WHERE option_name = 'blogname'");

    $blog_url = $wpdb->get_var("SELECT option_value FROM " .
    $wpmuBaseTablePrefix . intval($comment->blogid) . "_options" .
    " WHERE option_name = 'siteurl'");

    $post = $wpdb->get_row(
    "SELECT * FROM ".$wpmuBaseTablePrefix.intval($comment->blogid)."_posts
    WHERE ID = '".intval($comment->comment_post_ID)."'");

    $time_ago_str = wpmu_feedbag_ago_string(wpmu_feedbag_elapsed_time($comment->comment_gmt_date));

    print "<p style=\"margin-bottom: 0;\">\n";
    print $comment->comment_author . " commented " . $time_ago_str . " on " .
    "guid\">\"$post->post_title\"" .
    " on $blog_name";
    print "</p>";

    print "<p style=\"padding-left: 2em; margin-top: 1em;\">";
    print $comment->comment_content;
    print "</p>";
    }
    }

    function wpmu_feedbag_recent_posts($max_posts) {

    global $wpdb, $wpmuBaseTablePrefix;

    $post_info = wpmu_feedbag_get_post_info($max_posts);

    foreach ($post_info as $post) {
    $blog_name = $wpdb->get_var("SELECT option_value FROM " .
    $wpmuBaseTablePrefix . $post->blogid . "_options" .
    " WHERE option_name = 'blogname'");

    $blog_url = $wpdb->get_var("SELECT option_value FROM " .
    $wpmuBaseTablePrefix . $post->blogid . "_options" .
    " WHERE option_name = 'siteurl'");

    $post_author_name = get_author_name($post->post_author);

    print "<h2 style=\"margin-top: 2em;\">";
    print "guid\">";
    print $post->post_title;
    print "
    ";
    print "</h2>";

    print "<p>";
    print "";
    $time_ago = wpmu_feedbag_elapsed_time($post->post_date_gmt);
    $time_ago_str = wpmu_feedbag_ago_string($time_ago);
    print "
    Posted $time_ago_str\n";
    print " on $blog_name";
    print " by $post_author_name\n";

    if ($post->comment_count > 0) {
    if ($post->comment_count == 1) {
    print "
    1 comment\n";
    } else {
    print "
    $post->comment_count comments\n";
    }
    }
    print "
    ";
    print "</p>\n";
    print "<p>";
    echo preg_replace('@<pre(.*?)@si',"

    Code removed from this feed. See actual post for code.

    ",$post->post_content);
    print "</p>\n";
    }

    }
    ?>

  21. billdennis5
    Member
    Posted 15 years ago #

    Placed in the mu-plugin folder i assume?

  22. bwinn
    Member
    Posted 15 years ago #

    @jasonkuter

    Using this code, would there be a way to modify it to use multiple external feeds and combine them into one and display those on your homepage?

About this Topic

  • Started 15 years ago by billdennis5
  • Latest reply from bwinn