我有以下 WP 功能和我写的简码
function selected_inventory_products( $atts ) {
extract( shortcode_atts( array(
'brand' => '',
'product' => '',
), $atts ) );
global $wpdb;
$inventory_products = $wpdb->get_results("SELECT * FROM wp_inventory, wp_inventory_images WHERE wp_inventory.inventory_id = wp_inventory_images.inventory_id and sort_order = 0 and inventory_manufacturer = '".$brand."'");
foreach($inventory_products as $i_products){
$return_string = '<div style="background: #F4F4F4; width: 100%;">';
$return_string .= '<a href="http://www.devicemondo.com/products/item/'.$i_products->inventory_slug.'/">'.$i_products->inventory_name.'</a>';
$return_string .= '</div>';
}
return $return_string;
}
add_shortcode( 'post_sidebar_products', 'selected_inventory_products' );
问题是当我在我的 WP 页面中使用简码 [post_sidebar_products] 时,即使有超过 15 个结果,我也只能得到 1 个结果?知道我在哪里犯了错误吗?
感谢帮助