The MU forums have moved to WordPress.org

How can I list all blogs (33 posts)

  1. uncphan
    Member
    Posted 17 years ago #

    I want to list all of my users' blog sites on my front page. How can I do this?

  2. andrea_r
    Moderator
    Posted 17 years ago #

  3. lunabyte
    Member
    Posted 17 years ago #

    Would this work?

    get_blog_list(options)

    where options available are:

    start # (if you want it paged)

    num (number of results pp, or "all")

    display (t/f)

    Essentially doing the same thing as on the "home" page in the default theme, except using this function and setting options as (0,'all',1).

    Or am I reading that function wrong?

  4. andrea_r
    Moderator
    Posted 17 years ago #

    without me going and double-checking - yeah, that sounds right. :)

  5. lunabyte
    Member
    Posted 17 years ago #

    I was digging through wpmu-functions and found it. There's some neat goodies in there, besides that, as well.

  6. conpeo
    Member
    Posted 17 years ago #

    can i exclusive some deactivate blogs?
    thank you.

  7. lunabyte
    Member
    Posted 17 years ago #

    It should exclude those by default.

    The query runs these checks when it builds the list:


    WHERE site_id = '$wpdb->siteid'
    AND public = '1'
    AND archived = '0'
    AND mature = '0'
    AND spam = '0'
    AND deleted = '0'

    Which grabs only blogs for the current domain, which are publicly available, not archived, not "mature" (as in for mature audiences), not marked as spam, and not "deleted".

  8. pazcu
    Member
    Posted 17 years ago #

    use this pluggin... very easy..

    http://wpmudevorg.wordpress.com/project/List-All

  9. drmike
    Member
    Posted 17 years ago #

    Do you not see it linked to up above there?

  10. djsteve
    Member
    Posted 16 years ago #

    With either function, how should I go about putting the list on a page? (page referring to page instead of post)

    I thought creating a theme page for "page-11.php" might work, but from the research I have done, perhaps that only works with categories..?

    I can't put the php code in a page with the visual editor obviously.

    I'm wanting to make a page that lists all blog rather than having them all on the home page, but can't think of any way to use the list all code or the call for the list all plugin without putting it into a post and doing the custom category page, which mean that I can't use it on a page?

    I'm having code-brain freeze I guess, any help appreciated..

  11. peiqinglong
    Member
    Posted 16 years ago #

    If you want to use the list-all function on a page, make a page template and call it whatever and hard code the call in. Then make a new page using the newly created page template and bam, it works.

  12. djsteve
    Member
    Posted 16 years ago #

    code-brain freeze is still here, after a cup of tea and half a cup of coffee, sorry..

    I made a new page template, called it page-11.php, hardcoded it in, but I do not see any way to change the template called for this single page. (my main mu blog has a page for terms, that I do not want to have the list all hard coded for.. I also want to have another page that lists recent posts..

    anyhow, is there a way to select a different template for each individual page? I do not see any option like that on the page editor anywhere...

  13. lunabyte
    Member
    Posted 16 years ago #

  14. djsteve
    Member
    Posted 16 years ago #

    Thanks for the tips peiqinglong and luna - I have been all over those template areas.. and I have paused and then come back to them.. I am going deep and learning some new stuff which is awesome. I am stuck at this part:

    Toward the bottom of the Write->Write Page administration panel (or on the sidebar, depending on which version of WordPress you are using) is a drop-down labeled "Page Template". From there you can select which Template will be used when displaying this particular Page. NOTE: In order to access the Page Template selector, there must be at least one custom Page Template available in the active theme (se...

    I do not see this drop down list anywhere... I even opened up custom fields, there is a drop down there that has "_wp_page_template" - so for hits and giggles I tried that, then put my custom page title in there (which is already in the theme's folder) - "page-11.php"; and that did not work..

    Am I on the right track with the custom fields area being what the docs are talking about? Or is there some other drop down I am not seeing - nothing in the sidebar that says page template or anything...

  15. lunabyte
    Member
    Posted 16 years ago #

    No, you have to make a custom page template.
    Which, is covered under the hierarchy information.

  16. djsteve
    Member
    Posted 16 years ago #

    Woo-Hoo! I got it!

    For anyone else having this brain freeze; what I had to do:

    take the new page template I had made (which I had named page-11.php, and have since renamed to pagelistall.php and made a copy of that calling it pagerecentup.php) and add 5 lines of code at the top - giving each new page template a new "theme name".

    apparently for wordpress to give you the option for a new theme for an individual page in the editor page as described in the instructions, you have to have another theme "name" in the .php file that you want to use.

    So now I have two more page.php files that are renamed, and have the code at the top giving them a new theme name in wordpress' eyes, even though they are the same theme, they are named differently, so now I have a dropdown box in the sidebar where I can select them.
    http://codex.wordpress.org/Pages#Creating_your_own_Page_Templates

    I added the code that luna talked about in an earlier post to list all, and it's working. Very cool!

    Now if I can just figure out how to reverse the order with the code that luna suggested above, I'd be really happy!

  17. lunabyte
    Member
    Posted 16 years ago #

    Reverse the order of what? The query results?

    Like... ORDER BY x DESC? Basic mysql right there.

  18. djsteve
    Member
    Posted 16 years ago #

    Geeze! You make it sound so easy.. I have no clue where to put this kind of order stuff though, mysql in the php? Now I'm totally confused..

    I think I put this in a custom page template and it works:
    get_blog_list(0,'all',1)

    It brings up the full list, but they are from last to first created (newest being on top (new splogs lolo), and older being on bottom)

    what would the code variation be to reverse the order?

    I really appreciate the help! This is so cool!

  19. peiqinglong
    Member
    Posted 16 years ago #

    Sorry, I missed this thread somehow. Sorry I wasn't more clear, but glad you figured it out. Think of it this way, you'll never forget the answer ;)

  20. carnold
    Member
    Posted 16 years ago #

    I have made a page template and created a page with the new template. I have entered < ? php get_blog_list(0,'all',1); ? > but nothing is listed on that newly created page. What am i missing. Using 1.3

  21. andrea_r
    Moderator
    Posted 16 years ago #

    Do you have any sub-blogs and are they set to public?

  22. carnold
    Member
    Posted 16 years ago #

    I do have a couple sub-blogs and they are public.

  23. carnold
    Member
    Posted 16 years ago #

    I used peiqinglong's code on another post and this works. How do i now get a description of the blogs and say the first 50 words of their last post?

  24. carnold
    Member
    Posted 16 years ago #

    How would i pull the data for the blogs and list 1 post from that blog? I have tried to use part of a plugin but i can't get that to work

    OK, in wpmu-functions, i see get_blog_post:
    function get_blog_post( $blog_id, $post_id ) {
    global $wpdb;

    $key = $blog_id."-".$post_id."-blog_post";
    $post = wp_cache_get( $key, "site-options" );
    if( $post == false ) {
    $post = $wpdb->get_row( "SELECT * FROM {$wpdb->base_prefix}{$blog_id}_posts WHERE ID = '{$post_id}'" );
    wp_cache_add( $key, $post, "site-options", 120 );
    }

    return $post;

    }

    What psrt of this code will give me the post? I have tried the entire code, from $key to return $post and if to return $post. You can see here, http://mytimewithgod.net/blogs

  25. andrea_r
    Moderator
    Posted 16 years ago #

    I think you'll need more code for that. Also, i see your site is down.

  26. carnold
    Member
    Posted 16 years ago #

    Yea, the power went out for about 1 hour (or just after i posted that). What other code should i need?

  27. andrea_r
    Moderator
    Posted 16 years ago #

    I would take one of the most recent posts one and mesh it in there.

  28. carnold
    Member
    Posted 16 years ago #

    I only see one recent post in the wpmu-functions file, get_most_recent_post_of_user. Should this be used?

  29. andrea_r
    Moderator
    Posted 16 years ago #

    I meant a recent posts plugin, oops.

    (having heating issues here, cold typing fingers)

  30. carnold
    Member
    Posted 16 years ago #

    I prefer not to use a plugin. It is possible to do it without a plugin? I looked at your recent posts plugin at muwpdev. I use a plugin called simplepie for the news, i wonder if i could use that to display last post for each blog?

About this Topic

  • Started 17 years ago by uncphan
  • Latest reply from Oo7rockstar