Support » Plugin: Media Library Assistant » [mla_gallery] shortcode help

  • Resolved WebENFA



    I’m trying to display a text list of my 10 last uploaded and attached pdf files, from all pages sitewide.

    So far I managed to get a partial shortcode for this : [mla_gallery post_parent=all orderby=date size=none post_mime_type=application/pdf link=full]

    What I have trouble to do is :

    • only display “inserted” files (I tested with “post_status” but didn’t get any result)
    • limit to only 10 elements displayed

    Would you have an idea how to proceed ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have found one of my answer by looking through the mla_gallery shortcode php code :

    To limit to 10 results, we have to use “posts_per_archive_page=10” in the shortcode.

    But I have another issue, I changed orderby=date with orderby=ID and none seems to get me the last uploaded and attached documents, I can’t even find what order the shortcode choose to display.

    Plugin Author David Lingren


    Thanks for your question. You are on the right track; the orderby and posts_per_page parameters are part of the solution.

    For example, if you want to create a gallery of the three most recent PDF uploads, you can use:

    [mla_gallery post_parent=all orderby=date order=desc posts_per_page=3 post_mime_type=application/pdf link=file]

    The query parameters select all of the attachments (post_parent=all), sort them by upload date (orderby=date), put the most recent uploads first (order=desc) and then limit the gallery to three items (posts_per_page=3). The post_mime_type parameter selects PDFs, and the link parameter generates a link to the PDF document.

    I am not sure what you mean by “inserted” files. Do you mean files that are attached to a parent post/page? Or, do you mean files that are inserted in the body of a post/page? I think the best way to handle this with the current version of the plugin would be to assign a tag or category to the files you want to include and then add a parameter like attachment_tag=inserted to your query.

    I hope that answers your question. Please let me know if you need more information or have any problems getting what you want. Thanks for using the plugin!

    Thank you for you answer.

    First of all, the orderby parameter seems to order the results in a way I don’t understand when I don’t limit them to a mime type. If i use (orderby=date) or (orderby=ID) and (order=desc) without using (post_mime_type=pdf), my first displayed item’s id is 3252, but my most recent item’s id is 3793.
    BUT I found a workaround, I used (post_mime_type=all) and it works nice.

    For the “inserted” part, I mean the parameter you see in the “Assistant” list of the Medias menu in WordPress Dashboard, the column on the right displays “Inserted in” and the id/name of the page/post where the file is actually inserted in the page/post body.

    I have around 30 users and A LOT of files, most of users are not familiar with the process of publishing on wordpress eventhought they were trained many times (they are secretaries, teachers, administratives, all in their 50’s), and they upload the same file 4 to 5 times before inserting it in their page/post definitively, that’s why I need to display only the “Inserted” files in my list. Also, they have a great difficulty to understand the concept of tagging elements …

    It’s not a major issue so I’m going to put this post in “resolved” status, and thank you again for your help !

    Plugin Author David Lingren


    Thanks for this update and the additional information. I will have a closer look at the orderby issues you’ve raised and see if there’s a problem I can fix. I am traveling until February 12 and do not have access to my development system, so this will take a while. I will update this topic when I have news.

    If you have access to a development/test version of your site, you can try adding mla_debug=true to your query. You will see extensive information about your query in the page where the gallery occurs, including the query parameters passed to WordPress and the SQL statement used to access the database. This might give you a clue as to why you’re not getting what you expect. Don’t do it on a pubic site – it’s quite ugly.

    I can emphasize with your remarks on multiple uploads and insertion confusion; I have faced similar training and explanation challenges with my associates. It’s not one of WordPress’ most user-friendly features.

    The “inserted” topic is interesting. To compute the where-used columns requires searching through every post/page in the site and scanning the content for file names and shortcodes. Computing the “gallery in” status requires running each shortcode and recording the results. I try to do this economically because of the database access required.

    I am always working on ways to make this better, and you’ve given me a few new things to ponder. In the interim, you can try using the “custom fields” tab of the settings page to add status information to your attachments, then add a “meta value” query to your [mla_gallery] parameters to select attachments with a non-blank value in the “inserted in” field you’ve created. You will have to refresh this information when you need the latest results. You can use the “Map attachments now” button on the Settings/Custom Fields page for that, or select all the newest attachments on the Media/Assistant table listing and then use the bulk edit area to refresh the attachments you’ve selected. Not exactly automatic, but it might be useful for you.

    Let me know how this works out. Thanks again for your interest and your feedback!

    Plugin Author David Lingren


    I am back from my travels and following up on this issue. I have run some tests on my system and I cannot duplicate the odd “orderby” behavior you’ve described. I ran the following three tests:

    [mla_gallery post_mime_type=all post_parent=all columns=1 mla_itemwidth=50 mla_float=left size=none link=file orderby=date order=desc posts_per_archive_page=10 mla_caption="{+index+}: {+attachment_ID+}, {+date+}" mla_debug=true]

    [mla_gallery post_mime_type=application/pdf post_parent=all columns=1 mla_itemwidth=50 mla_float=left size=none link=file orderby=date order=desc posts_per_archive_page=10 mla_caption="{+index+}: {+attachment_ID+}, {+date+}" mla_debug=true]

    [mla_gallery post_parent=all columns=1 mla_itemwidth=50 mla_float=left size=none link=file orderby=date order=desc posts_per_archive_page=10 mla_caption="{+index+}: {+attachment_ID+}, {+date+}" mla_debug=true]

    All of these produced lists sorted by date in descending order.

    If you can give me the shortcode parameters you are using I can have another look. If you have access to a test system, perhaps you can use the shortcode parameters I’ve listed above and send me the output containing the gallery listing and the debug information.

    The best way to proceed would be to send me your e-mail address and I will send you an address you can use to e-mail me your additional information. Go to the “Contact Us” page at our web site:

    Fair Trade Judaica/Contact Us

    By the way, did you ever try the custom field/meta query idea I suggested?

    Thanks for your interest and for your patience. I look forward to hearing from you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[mla_gallery] shortcode help’ is closed to new replies.