For MLA users who come across this topic in the future I am adding a partial solution to the second problem, “how to query something other than the wp_posts
fields. The “MLA UI Elements Example” plugin supports some simple date-based queries on the content of a custom field.
To install (or update) the example plugin, navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “elements” in the text box and click “Search Plugins” to filter the table.
You are looking for the “MLA UI Elements Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “Update” (or “Install”) rollover action, then go to the WordPress Plugins/Installed Plugins submenu and verify or activate the example plugin as you would any other plugin.
Once the example plugin is installed you can follow these examples:
You can use the [mla_gallery]
parameters by themselves to filter a gallery display by date values. This is particularly useful when you want to filter based on a date held in a custom field, which the core WordPress date parameters and date query do not support. For example, if you have a custom field named “Publication Date” and want to display what was published in 2020 you can code something like:
[mla_gallery post_parent=all archive_parameter_name=muie_current_archive muie_current_archive="custom:Publication Date,Y(2020)"]
Note the use of post_parent=all
to overide the default display of items attached to the current post/page. You can use the current_timestamp
, current_datetime
and current_getdate
field-level data sources to, for example, return items published in the current month. Code something like:
[mla_gallery post_parent=all archive_parameter_name=muie_current_archive muie_current_archive="custom:Publication Date,M({+current_datetime,date( 'Ym' )+})"]
By adjusting the format code you can specify any of the four archive types: daily ‘Ymd’, weekly ‘YW’, monthly ‘Ym’, yearly ‘Y’.
These features are part of the [muie_archive_list]
shortcode. Once the plugin is installed you can find more information in the Settings/MLA UI Elements Documentation tab.