Thanks for your good words regarding the plugin and for your question. Thanks as well for the details on your application and for posting your shortcode source text.
The s=2015
parameter in your shortcode is a “Keyword search” parameter; it looks in the item Title and Description fields for a match. You can extend that to a few other fields, but it will not look in custom fields. See the “Keyword(s) Search” section of the Settings/Media Library Assistant Documentation tab for more details on this parameter.
Your application requires a “meta_query” as described in the “Custom Field Queries, the ‘meta_query’ ” section of the Documentation. You could use the “Simple Custom Field Parameters” to search for an exact match, but you want “all values beginning with 2015”, so the more powerful version is required.
Here’s a query that replaces your s=2015
parameter:
meta_query="array( array( 'key' => 'YYYY-MM', 'value' => '2015', 'compare' => 'LIKE' ) )"
Each key/value/compare clause is coded as an array. The second array lets you add more clauses and options to the query. For example, you can extend the query to multiple years with something like this:
meta_query="array( relation => 'OR', array( 'key' => 'YYYY-MM', 'value' => '2015', 'compare' => 'LIKE' ), array( 'key' => 'YYYY-MM', 'value' => '2014', 'compare' => 'LIKE' ) )"
You can see the second clause and the relation => 'OR'
option to accept either 2015 or 2014.
With the meta_query
, your example shortcode becomes:
<code>[mla_gallery columns=1 attachment_category="Newsletter" post_mime_type=application/pdf meta_key="YYYY-MM" orderby=meta_value order=DESC link=file mla_itemwidth=25 meta_query="array( relation => 'OR', array( 'key' => 'YYYY-MM', 'value' => '2015', 'compare' => 'LIKE' ), array( 'key' => 'YYYY-MM', 'value' => '2014', 'compare' => 'LIKE' ) )"]</code>
Here are a few other tips for entering this somewhat complicated shortcode:
- Be sure the use the Text tab of the post/page editor, not the Visual tab.
- Be sure to enter the entire shortcode on one line; do not break it up – that confuses the WordPress shortcode parser.
- Be sure the put
<code>
and </code>
tags around the entire shortcode. Recent versions of WordPress mangle the special characters like “=>” in the query if you don’t add the tags.
That should get you the results you seek. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestions. Thanks again for the kind words and for your interest in the plugin.