The MU forums have moved to WordPress.org

php code for most recently updated blog (42 posts)

  1. wugga
    Member
    Posted 20 years ago #

    Have you tried using the builtin function to see if you have any better results?

  2. mydietblogger
    Inactive
    Posted 20 years ago #

    meaning
    '<?php get_last_updated(); ?>'

    Yeah, I get errors with that. Refresh and you will see the errors that result from the above code.

  3. mydietblogger
    Inactive
    Posted 20 years ago #

    I dont want my main page to look crazy, so I am going to post what the errors are with <?php get_last_updated(); ?>

    '

    WordPress database error: [Table 'sskhalsa_wpmu.wpmu__options' doesn't exist]
    SELECT option_value FROM wpmu__options WHERE option_name = 'is_archived'

    WordPress database error: [Table 'sskhalsa_wpmu.wpmu__options' doesn't exist]
    SELECT option_value FROM wpmu__options WHERE option_name = 'is_archived'
    '

  4. wugga
    Member
    Posted 20 years ago #

    I think you missed this part of the post. There is a bug where a comma is missing after blog_id in the second line of the function. ... add the command and I think things will be OK for you. You still will have to iterate thru the data to display it however you like.

  5. mydietblogger
    Inactive
    Posted 20 years ago #

    Thanks for your response.

    I did see that, but where is the function I need to add the comma too? In wpmu-functions.php ? What would I look for.

  6. Ovidiu
    Member
    Posted 18 years ago #

    seeing that this is an old post I am still curious what is the most elegant way t odisplay the last 10 updated blogs in my sidebar? not displaying their url, but their name though...

    I tried <?php get_last_updated(); ?> but that gives me no output at all...

    I looked at wp-includes/wpmu-functions.php and the function looks like this:

    function get_last_updated( $display = false ) {
    global $wpdb;
    $blogs = $wpdb->get_results( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = '$wpdb->siteid' AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted....

    return $blogs;
    }
    I cut the function off in the middle the line was too long.

    what baffles me is that $display = false - do I have to set it to true to get my results? does that affect anything else?

  7. lunabyte
    Member
    Posted 18 years ago #

    By default (I think) that shows 40 blogs.

    What (most likely) you're wanting to do is return the results, and output them in a foreach loop. This is exampled in the "home" theme, in home.php.

    If you only want 10, then you can either set a counter before the foreach loop and increment it on every pass, then check before your output if the value of the counter is > than the number of results you want. If it is, then the if should execute a continue statement. Then below that would be your output.

    Or you could do the same thing in a for loop as well. Personal preference on that one for the most part.

  8. Ovidiu
    Member
    Posted 18 years ago #

    :-(
    way over my head, could you give me some sample code I could manually put into my sidebar?

  9. lunabyte
    Member
    Posted 18 years ago #

    What (most likely) you're wanting to do is return the results, and output them in a foreach loop. This is exampled in the "home" theme, in home.php.

  10. Ovidiu
    Member
    Posted 18 years ago #

    I had a look into my home.php still I am not getting what you are hinting at :-(
    I guess you want me to see in home.php that the posts that are displayed are done so by a loop? but my sidebar content is outside of the loop!?

    sorry for being so noobish, I just suck at creating things, although if you give me some more hints I am able to modify stuff to suit my needs ;-)

  11. lunabyte
    Member
    Posted 18 years ago #

    I'm not trying to hint about anything.

    The home theme, in home.php call the latest updated blogs. That's it. No cryptic message or nothing, the code is right there.

  12. Ovidiu
    Member
    Posted 18 years ago #

    :-(
    thx, got it.... I was looking into the wrong home.php, did not notice I was not in the right theme....

    thx a lot

About this Topic