WordPress.org

Ready to get started?Download WordPress

Forums

Problems with showing random and limited bookmarks (1 post)

  1. probeus
    Member
    Posted 5 years ago #

    All new to this forum, so please forgive me if it is the wrong forum.

    I am trying to create a plugin/widget that shows 5 randoms bookmarks from the links database.

    this is what i got:

    function widget_content(){
      global $wpdb;
      $results = $wpdb->get_results("SELECT * FROM $wpdb->links WHERE link_visible ='Y'");
      $results = shuffle($results);
      $results = array($results);
      $results = array_slice($results, 0, 5);
    
      echo "<ul>";
    
        foreach ($results as $input) {
          $name = $input->link_name;
          $desc = $input->link_description;
          $url = $input->link_url;
            echo "<li>";
            echo "<a href=\"$url\">$name</a>";
            echo "</li>";
        }
    
      echo "</ul>";
    }

    Any idea what i am doing wrong?

    - Probeus

Topic Closed

This topic has been closed to new replies.

About this Topic