Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
1 of 2

How to show random feed from DB and show content in my site

I try to get more than 3 feed from other web site and show it in my site like :

function fw_shortcode( $atts ) 

    global $wpdb ,$feedtable;
    $result=mysql_query("SELECT * FROM ".$feedtable." ORDER BY RAND() LIMIT 3");
 $rss = fetch_feed($row["weburl"]);
 if (!is_wp_error( $rss ) ) : 
    $maxitems = $rss->get_item_quantity(1);
    $rss_items = $rss->get_items(0, $maxitems);
    foreach ( $rss_items as $item ) :

$code .= '<article class="col-md-4 col-sm-6 col-xs-12" itemscope="" itemtype="http://schema.org/BlogPosting">
<div class="vendoritem">';
$code .= '<a href="'.esc_url( $item->get_permalink() ).'"  target='."_blank".'>';
$code .= '<img width="300" height="225" src="' .get_first_image_url($item->get_description()). '" class="img-responsive relat wp-post-image" style="background-color:#3498db;">';
$code .= '</a>
<div class="vendoritem__details">
<a href="'.esc_url( $item->get_permalink() ).'" class="vendoritem__title" target='."_blank".'>
'.esc_html( $item->get_title() ).'</a>
/* End Loop */
$code .= '</div>';
return $code;

My problem is i need to shoe only random 3 feed from table. but some time show me 2 feed, Why !!, and if any feed not work, how can get other feed from DB