限制返回的结果数量

时间:2011-08-08 23:07:31

标签: post limit attachment

如何限制返回的结果数量?

$images = $wpdb->get_col("
    SELECT ID FROM $wpdb->posts
    WHERE post_type = 'attachment'
    AND ID in ($meta)
    ORDER BY menu_order ASC
");

1 个答案:

答案 0 :(得分:0)

要限制为5行,请使用以下查询:

$images = $wpdb->get_col("
    SELECT ID FROM $wpdb->posts
    WHERE post_type = 'attachment'
    AND ID in ($meta)
    ORDER BY menu_order ASC
    LIMIT 5
");