When I try to sort a Gallery created through the [gallery]
shortcode by numerical titles I get them sorted in alphabetical order. That means that they are sorted like so:
1, 3, 34, 4, 56, 6, etc.
rather than so:
1, 3, 4, 6, 34, 56, etc.
Doing some research I came across the section of the codex (in WP_Query
) explaining this issue. Apparently, setting the orderby
parameter to meta_value_num
would enable numerical sorting.
Since [gallery]
internally uses get_posts()
(wp-includes/media.php::714
), which in turn uses WP_Query
, I thought the same rules would apply.
Changing the order_by
attribute in the shortcode to meta_value_num
doesn't do the trick. I guess that most likely this is the case because I cannot set up the required meta_key=keyname
.
But not only can I not specify the meta key, I don't have one, and I don't need one because I mean to sort them numerically by title.
[gallery link="file" columns="6" orderby="title"]
which gives the alphabetical order and[gallery link="file" columns="6" orderby="meta_value_num"]
which, as stated, doesn't do anything.