Thanks for your kind words regarding my plugin support and for your question. Thanks as well for posting the details and example shortcode for your application.
Your current shortcode will never return results because the category
parameter (as defined by WordPress) will not accept the general tax_query
type of syntax. It is limited to one or more Category slug values. Also, it will look for the slug values assigned to the attachment items, not in the posts/pages they are attached to.
Your tax_query
parameter looks good except that the field => 'id'
portion should be field => 'term_id'
. You might try an experiment where you remove the category
parameter, fix the tax_query
and run a few tests to verify that the shortcode returns all of the items not assigned to term_id
53.
Your current s="{+request:search-string+}"
parameter will match all of the items in the Media Library if no search-string
appears in the request. If you want to show no items until a search-string
is entered you can use something like s="{+template:({+request:search-string+}|a-bad-value)+}"
, where a-bad-value
is anything that will not be matched by an item in the Media Library.
You wrote “exclude results which are attached to posts in certain categories“. There is no way I know of to express this part of your criteria with the WP_Query
class MLA uses to find items for [mla_gallery]
. You can, however, use the hooks built in to [mla_gallery]
to replace the WP_Query
database access with your own custom SQL query to achieve your goal. This approach would require some PHP code in your theme’s functions.php
file or a small custom plugin. There are two examples of similar plugins in the /media-library-assistant/examples/
directory:
mla-tax-query.php.txt
– A straightforward example that replaces tax_query
searches with a faster SQL alternative.
alexa-paige-plugin.php.txt
– A more complex example that includes shortcodes for generating an HTML form with checkboxes for taxonomy tem searches.
If the PHP/custom plugin approach will work for you I can give you more specific guidance on adapting the code to your application. Let me know how you would like to proceed. Thanks for your interest in the plugin.