我尝试从其他网站获取3个以上的提要,并将其显示在我的网站上,如:
function fw_shortcode( $atts ) {
global $wpdb, $feedtable;
$result=mysql_query("SELECT * FROM " . $feedtable . " ORDER BY RAND() LIMIT 3");
while( $row=mysql_fetch_array($result) ) {
$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>
</div>
</div>
</article>\';
endforeach;
endif;
/* End Loop */
}
$code .= \'</div>\';
return $code;
wp_reset_query();
}
我的问题是我只需要从表中随机选择3个feed。但是
some time 给我看2个feed,为什么!!,如果任何feed都不起作用,如何从DB获取其他feed