The MU forums have moved to WordPress.org

Exclude blogs from recent posts (10 posts)

  1. Konstan
    Member
    Posted 16 years ago #

    I am trying to make a newer front page for my site and I've been trying to add the latest updated blogs, created blogs amd recent comments to it.

    For updated blogs, I am using WordPress MU Recent Posts and it works fine as far as I can see, but I cant exclude more then 1 blog and I'd like to exlude several.

    $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE
    	  public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND
    		last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL 5 DAY)
    		ORDER BY last_updated DESC");

    I tried adding AND blog_id != 'x' but it only works for 1 blog, I cant add x, y, z :( How can I do this?

    Also, are there any other plugins that do this? What I really need is to show Latest X posts, including a link to the post, the author and post time. Excluding the hello word posts (but I'll get to that later).

    Someone please help :(

  2. indojepang
    Member
    Posted 16 years ago #

    never done this before, but u could try to set the blog public setting to no, i think it will exclude that blog from the post

  3. tdjcbe
    Member
    Posted 16 years ago #

    It would but it would also keep the blog out of search engines. Setting it as mature may be better as the search engine spiders wouldn't be blocked.

    I'm sure there is a way to create an array within a site_option record and check against that but I'm drawing a blank.

  4. Konstan
    Member
    Posted 16 years ago #

    Exactly, if I set the blog to private it wont get indexed by google. I guess I'll have to mark them as mature then.

  5. lunabyte
    Member
    Posted 16 years ago #

    AND blog_id != '1' AND blog_id != '2' AND blog_id !='45'

    So on and so forth.

    If you only have a few to include, it may be shorter to use blog_id = '1', vice using the !=.

    Basic mysql syntax right there.

  6. Konstan
    Member
    Posted 16 years ago #

    I want to exlude like 15 blogs :( Thats too many AND :P

    I dont think it'll slow down the query too much if I add 15 more AND ?

  7. lunabyte
    Member
    Posted 16 years ago #

    Not really.

    Hundreds and hundreds, maybe, but blog_id is indexed, so it shouldn't make a dent.

  8. Konstan
    Member
    Posted 16 years ago #

    Thanks :) It works...but I am still not really satisfied with it. I'd like to change the guid link to the real permalink. Otherwise it seems to work ok.

    I also tried the sitewide feed approach but the plugin is not totally working for me (I posted in that thread).

  9. lunabyte
    Member
    Posted 16 years ago #

    Well, you have a post and blog id. Look up some of the permalink functions, and see what they do.

  10. Konstan
    Member
    Posted 16 years ago #

    I am trying :)

    So far I cant get it to work, but I'll keep working on it.

About this Topic