WordPress.org

Ready to get started?Download WordPress

Forums

Making this php function random (2 posts)

  1. anabelle
    Member
    Posted 7 years ago #

    Hi, this function, is from the wp_random quote plugin, it outputs a list of all quotes, ordered by id. How can i make it to output the list in a randm order...

    i know this is a minor code change but i can't remember how it's done.

    here is the function:

    function wp_quotes_page($data)
    {
    $start = strpos($data, WP_QUOTES_PAGE);

    if ( $start !== false )
    {
    ob_start();

    global $wpdb;

    $sql = "select * from " . WP_QUOTES_TABLE;

    $result = $wpdb->get_results($sql);

    if ( !empty($result) )
    {
    $count = 0;
    foreach ( $result as $row )
    {
    if ( $count++ > 0 )
    echo "<hr class=\"wp_quotepage_hr\">n";

    wp_quotes_spew($row, 'class="wp_quotepage"', 'wp_quotepage_quote', 'wp_quotepage_author');

    }
    }
    echo "<div class=\"wpquotes_poweredby\">Powered by <a href=\"http://www.zombierobot.com/\">Zombie Robot wp-quotes plugin</a>.</div>n";

    $contents = ob_get_contents();
    ob_end_clean();

    $data = substr_replace($data, $contents, $start, strlen(WP_QUOTES_PAGE));
    }

    return $data;
    }
    add_filter('the_content', 'wp_quotes_page', 10);
    ?>

    Thanx

  2. anabelle
    Member
    Posted 7 years ago #

    is it that hard?

Topic Closed

This topic has been closed to new replies.

About this Topic