Thanks for your question and for the reference to the Simple Location plugin. Thanks as well for digging through the Documentation and finding the ,extract(p,v)
option/format value, which is a part of the answer.
I installed and activated the Simple Location plugin on my system and ran some tests, which gave a solution for your application.
You can use MLA’s regular expression option/format values and one of the MLA Example Plugins to accomplish your task. The regular expression values let you parse the geo_address
value into its component parts and re-arrange them.
For your application, this content template should do the job:
template:[+custom:geo_address,extract('/(?<city>[^, ]*), (?<region>[^,]*), (?<country>.*)/')+](/[+matches:country+]/[+matches:region+]/[+matches:city+])
The template accesses the custom:geo_address
field that contains values such as your example, “Horsley, Northumberland, United Kingdom”. The extract
pattern parses it into three individual fields; city, region and country. The final portion, (/[+matches:country+]/[+matches:region+]/[+matches:city+])
, assembles the three-term hierarchical path you need to populate the taxonomy terms. The parentheses around this portion will bypass any values that do not contain all three levels.
The “MLA Path Mapping Example” plugin lets you specify a complete, multi-level path for adding hierarchical term relationships to a taxonomy. The example plugin has a Settings screen with a Documentation tab that explains how to use it. In particular, the settings let you decide on which parts of the hierarchiy to assign to each item.
To install the example plugin, navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. You will see a table that lists all the example plugins and gives you a “one-click” action for installing them. Type “path mapping” in the text box (including the quotes) and click “Search Plugins” to filter the table. You are looking for “MLA Path Mapping Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “Install” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and activate it as you would any other plugin.
Once the example plugin is active you can define a mapping rule to create and assign the geo_address
terms:
- Go to the Settings/Media Library Assistant IPTC/EXIF tab.
- If you want to apply the rule to new items as they are uploaded, check the “Enable IPTC/EXIF Mapping when adding new media” and “Enable IPTC/EXIF Mapping when updating media metadata” boxes.
- Locate the “Att. Categories” rule entry in the table and click the “Edit” rollover action.
- In the “IPTC Value” dropdown control leave the default “- None (select a value) -” in place.
- In the “EXIF/Template Value” text box enter the Content Template given above.
- In the “Priority” dropdown, select “EXIF”.
- In the “Existing Text” dropdown, select “Replace” to replace existing term assignments or “Keep” to add the terms generated by the rule to any existing assignments.
- Scroll down to the bottom of the screen and click “Update”.
Once you define a rule you can apply it to a single item, multiple items or all items:
- To map a single item, go to the Media/Assistant submenu and click the thumbnail of the item you want (or click the “Edit” rollover action) to get the Media/Edit Media screen. You can click the “Map IPTC/EXIF metadata” link to run your rules on this item, then scroll down and look at the “Att. Categories” meta box to inspect the results.
- To map two or more items, go to the Media/Assistant submenu and click the checkbox next to the items you want. Then, select “Edit” from the “Bulk Actions” dropdown above the checkboxes and click “Apply” to open the Bulk Edit area. Click the “Map IPTC/EXIF metadata” button to run your rules on the selected items.
- To map all of your items, stay on the Settings/Media Library Assistant IPTC/EXIF tab and click the “Execute” rollover action for the App. Categories rule. This may take a while.
I hope you can combine the example plugin with the regular expression option/format parameters to get the results you seek. I will leave this topic unresolved for now in case you have problems or further questions regarding the above suggestions. Thanks for your interest in MLA.