The MU forums have moved to WordPress.org

Sitewide Latest Posts (30 posts)

  1. streaky
    Member
    Posted 15 years ago #

    I'm trying to get my head round how to gather together latest posts for an entire site.

    It's doable by running through all the blogs and pulling out the newest posts but that's about as scalable as a 40 foot wall.

    Obviously it's possible to hack the code apart and insert new posts into a new table, far more scalable but slightly more annoying and prone to various errors.

    Just realising that this is an obvious problem caused by giving each blog it's own set of tables.

    What I'm wondering is if anybody has done it before and could share some info on how they did it?

  2. demonicume
    Member
    Posted 15 years ago #

    there's a plugin that doesnt that already, isnt there?

  3. andrea_r
    Moderator
    Posted 15 years ago #

    ...and in the latest download the default home.php has stuff in there too I think.

    I think people have found that pretty scalable so far. I mean, you don't have to shuffle through every table of every blog if you've first knocked off everything that hasn't been updated in the last X amount of time.

  4. streaky
    Member
    Posted 15 years ago #

    Just looking I've found http://wpmudevorg.wordpress.com/project/Most-recent-posts - which y'know - works.

    It'll do for now but I'm not totally convinced of the sanity of it, I can imagine a situation where there's 10,000 new posts today across 6,000 blogs and we get a few page views a minute, it's gonna get really messy, really fast.

    I'll use this for now and see why I can figure out, hopefully I'll figure out some complicated query that MySQL can optimise better.

  5. andrea_r
    Moderator
    Posted 15 years ago #

    My hubby wrote that one. :) (and I posted it) He works with huge dbs all day.

    Your other option is to get the Sitewide Feed plugin and pull that in where you want it. Same thing, done differently.

  6. demonicume
    Member
    Posted 15 years ago #

    feed + simplepie , i guess.

  7. streaky
    Member
    Posted 15 years ago #

    My hubby wrote that one. :) (and I posted it) He works with huge dbs all day.

    Heh, I don't doubt it works and works well, I guess I'm just obsessive-compulsive about stuff like that, I can see on a big site the first query is going to return a huge result set - at least considering you only need about 10 of them.

    I'm actually half tempted to LIMIT say double the $how_many and work backwards from there - the other benefit to that is sites that don't get 10 'global' posts per day aren't limited by it either, i.e. it'll show the last 10 posts no matter if they are posted that day or not.

    I'll let you all know how the search goes.

  8. streaky
    Member
    Posted 15 years ago #

    Well I hacked it a bit and came up with http://mybrokenlogic.com/stuff/sitewide_recent_posts.phps - it's still not perfect, there's places where the order could get skewed slightly, but I think it's potentially slightly more accurate than the original.

    Of course the initial result set is much smaller and it doesn't include results from deleted, spam and private blogs.

    I also added a

    <ul>
    tag around the list items.

    I'm gonna keep adding to it, if you're interested I'd keep checking it because I'm going to add better sorting so it actually gets the correct posts in the correct order - will add another note when I do that.

  9. Farms2
    Member
    Posted 15 years ago #

    Thanx for sharing :)

  10. suleiman
    Member
    Posted 15 years ago #

    thanks for your work streaky :) much appreciated!

  11. banjolawyer
    Member
    Posted 15 years ago #

    Hi: Is this a plugin or code to be added to a home.php page?

  12. andrea_r
    Moderator
    Posted 15 years ago #

    Yes. :)

  13. SteveAtty
    Member
    Posted 15 years ago #

    I notice you use the GUID as the permalink. If anyone ever changes their permalink structure then the GUID is then wrong.

    It does seem to be a common practice but its just asking for trouble.

  14. streaky
    Member
    Posted 15 years ago #

    Well I was hacking the original, what's a better way than GUID?

  15. SteveAtty
    Member
    Posted 15 years ago #

    get_blog_permalink( blog_id,post_id)

    will always return the current permalink for post_id in blog_id

  16. quenting
    Member
    Posted 15 years ago #

    as a general advice, creating a global post cache table is one of the best decisions i ever took to help with sitewide functionnality development.
    just my 2c.

  17. demonicume
    Member
    Posted 15 years ago #

    splitting hairs, whats the difference in functionality between the original get_recent comments and this one. i ask because i dont quite get all the guid-speak.

  18. streaky
    Member
    Posted 15 years ago #

    I's not comments it's posts, like.. blog posts.

    Back on track, I've come up with a new idea, gonna have a play later at using MySQL triggers to handle updating another table with new posts, if I'm right it should work out really well.

  19. banjolawyer
    Member
    Posted 15 years ago #

    andrea: mine was an either or question. Your response sounds like you can use this code as both a plugin and included in home.php.

    I created a php file and activated it as a plugin, but got nothing on my homepage. Should that have worked for me?

    Are you saying it is also possible to add the code to a home.php file and have it work?

  20. suleiman
    Member
    Posted 15 years ago #

    banjo, it is possible to do that, yes.

  21. andrea_r
    Moderator
    Posted 15 years ago #

    You *either* add a line of php to call the plugin funtion to whatever file you want - it;s listed how right at the top of the file
    OR
    you can add the whole file to whatever php file you want.

    Pretty much the same as a lot of plugins/code.

  22. banjolawyer
    Member
    Posted 15 years ago #

    Ugh. Its the story of my life. I just can't get this to work either way. Maybe its because I'm using one of the mu themes I downloaded from Farms big theme pack on wpmudev.org.

  23. drmike
    Member
    Posted 15 years ago #

    Might help if you tell us where you're having the issue else all we can do is make guesses and you don't want to do that with this crowd. :)

    At least a link.

  24. banjolawyer
    Member
    Posted 15 years ago #

    I'm sorry for omitting that.

    I uploaded sitewide_recent_posts.php to mu-plugins, but when I went to activate it, the plugin did not appear. So I uploaded it to the plugins folder, and I was able to activate it. However, I'm not getting any results on the homepage of the site.

    So I added the code to a home.php page and uploaded the home.php page to my custom theme directory. I'm using the newsportal theme currently. Still no results displaying on the site's homepage.

    The site is http://www.healthlawcounsel.com

  25. fogster
    Member
    Posted 15 years ago #

    I'm a (very) recent convert from MovableType, so I apologize for the fact that this is surely a really dumb question...

    Can someone walk me through how to set this plugin up? (Or point me to a primer on the subject?) I'd like for the main page of the blogs to simply be a listing of the most recent posts from the other blogs. Should I make a 'static page,' then, and set that as the main page?

    I usually hate questions from people who don't even have a clue, but now I'm on the other side of it. I don't even know where the home.php file is, or how to enable an uploaded plugin, much less how to get this working. Thanks in advance for any help! (Ideally, it'd be within a WP 'page' or whatnot, so that I can use a pre-existing theme.)

  26. ewald
    Member
    Posted 15 years ago #

    It would be awesome if the script would be capable of fetching the first X characters of a post and print it.

  27. banjolawyer
    Member
    Posted 15 years ago #

    >>>>I'd like for the main page of the blogs
    >>>>to simply be a listing of the most recent
    >>>>posts from the other blogs.

    This is what I'm hoping for also.

  28. andrea_r
    Moderator
    Posted 15 years ago #

    then you mostly have to customize your theme. The plugin can't do that part for you.

  29. Radecki
    Member
    Posted 15 years ago #

    ewald see the thread http://mu.wordpress.org/forums/topic.php?id=5352&replies=19

    I modded the ah recent posts plugin to include the first 120 words of the post, post author, blog and date.
    http://blogs.itworldcanada.com/code/ah-recent-posts-mu-mod.txt

    You should know that i strip out all the html characters from the post_content as i am only showing a paragraph or 2 too keep away from having huge posts take over the main blog page. I had to strip out html because before i was every once and a while truncating the text in the middle of an open html tag.......oops = messed everything up real bad for a while until i figured out what was going on.

    resave .txt file as ah-recent-posts-mu.php and add in mu-plugins file then in your home.php file simply call.

    <?php ah_recent_posts_mu(10) ?>

  30. ewald
    Member
    Posted 15 years ago #

    lovely, thanks a lot radecki!

About this Topic