This evening, I discovered a minor issue in version 0.3a of the List Attachments Shortcode plug-in. The problem was with the use of the orderby parameter. Because of some code related to the groupby parameter, the orderby parameter was ignored unless the groupby parameter was also set. This new version corrects that issue, so that you should be able to successfully use any of the orderby parameters available to the
get_posts() function in WordPress.
Tip for Usage:
Since I mentioned the groupby parameter above, I thought I’d include a little tip on how to use it. This tip will most likely be included in the next version’s readme file.
When it comes to attachments in WordPress, the following labels translate to the following database fields:
- The content of the Title field is stored in the “post_title” column in the database.
- The content of the Caption field is stored in the “post_excerpt” column in the database.
- The content of the Description field is stored in the “post_content” column in the database.
Therefore, if you are interested in grouping your attachments in specific sub-groups, you might want to use the “Caption” or “Description” field when uploading the attachments. Then, you would tell the shortcode to group your attachments by either “post_excerpt” or “post_content” (or, with newer versions of WordPress, you could just use “excerpt” or “content”).
For instance, let’s say you were posting a batch of stories written by three or four different authors. You could use the “Title” field to list the title of each document, then place the author’s name in the “Caption” field for each document. You would then use
[list-attachments orderby="title" groupby="excerpt"] to display the attachments in a list grouped according to author, then organized by title.