Thanks for your good words and for your question. I believe the answer will be similar to the technique outlined at the end of this recent support topic:
Using tag cloud shortcode to display galleries
You can use a Content Template to suppress the gallery display until you enter a search string. Try something like this:
$posts_per_pageval = 20;
echo do_shortcode('[mla_gallery mla_alt_shortcode="gallery" size="medium" link="file" posts_per_page=' . $posts_per_pageval . ' columns="0" type="rectangular" orderby="menu_order" post_parent=all s="{+template:({+request:s+}|a-bad-search string)+}" ]');
In this example:
- The template: prefix says that this is a Content Template
- The parentheses “()” around the two elements are used to group them into a list of alternatives
- The vertical bar “|” between the two elements means “stop when you get a non-empty alternative
- {+request:s+} will be empty unless there is a “s” parameter in the URL
- a-bad-search string is a literal value (and thus never empty) which does not match any title or description of a media item, so the gallery will be empty if this alternative is used.
You can read all about it in the “Content Templates” section of the Settings/Media Library Assistant Documentation tab, but the example should work as-is. Let me know if that resolves your issue.
On my system, using “s” for the parameter did not work; I used “x” instead. Using “s” confused WordPress, which went looking for a post or page on its own. Since you are using your own PHP code, this may not affect you.
I am marking this topic resolved, but please update it if you have any problems or questions regarding my proposed solution. Thanks for your interest in the plugin.