• Resolved bart85

    (@bart85)


    As a beginner I can’t figure out how to use the shortcodes/parameters.

    I want a search field on a page which uses only the keywords from Att. Tags to find matching photos. (I mapped the photo keywords to this field)
    I don’t want it to search through any other information, like title, caption.

    What I did so far, I used the “search from and gallery” example from the documentation. I put the html code on the page and added the shortcode as in the example: [mla_gallery s="{+template:({+request:search-string+}|a-bad-term)+}" mla_nolink_text="Enter a search value above to display gallery."]

    So, what do I need to change to make the search only use the Att. Tags information ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for finding and applying the “search form and gallery” example in the Settings/Media Library Assistant Documentation tab and for your question. Adding a couple of parameters to your shortcode should get you the results you seek.

    In the “Keyword(s) Search” section of the Documentation tab you can find these two parameters:

    • mla_search_fields – The fields in which to search. Choose from title, name, excerpt, content, alt-text, file, terms.
    • mla_terms_taxonomies – If you include ‘terms’ in mla_search_fields, you can add a comma-separated list of the taxonomy or taxonomies in which to search. Enter the slug(s) for one or more of the taxonomies registered for Media Library items, e.g., attachment_category or attachment_tag. If this parameter is omitted or empty, default taxonomies are specified in the Taxonomy Support section of the General tab.

    So, for your example, try something like this:

    [mla_gallery s="{+template:({+request:search-string+}|a-bad-term)+}" mla_search_fields=terms mla_terms_taxonomies=attachment_category mla_nolink_text="Enter a search value above to display gallery."]
    

    I’ve added the two new parameters just after the s= parameter.

    At the end of the “Keyword(s) Search section you will find this additional tip:

    The mla_search_fields=terms feature is a simple way to extend the search to the terms assigned to Media Library items. If searching on taxonomy terms is your primary goal, consider the more powerful “Taxonomy term keyword(s) search” parameters discussed in an earlier Documentation section.

    The terms search feature gives you additional capabilities but requires a bit more work on your part and some explanation of the search syntax for your users. You can decide if that’s worth pursuing for your application.

    I am marking this topic resolved, but please update it if you have problems or further questions regarding the above suggestions. Thanks for your interest in the plugin.

    Thread Starter bart85

    (@bart85)

    Great, thanks for your quick reply and the example. This was the little push I needed to understand how to implement these parameters and it works fine now.

    There is just one more question that comes up now I have this working and I tried some searches.
    I read through the Taxonomy term keyword(s) search documentation, what I want isn’t very complicated but one thing would be nice.
    As explained in the documentation the user has to add single quotes to find the word as a whole. So I the user searches for ‘man’, only this will come up as result and not woman (to keep the doc’s example).

    Is it possible to implement this as a standard using parameters, so always only the whole word is used, without the need for the user to type quotes ?

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the good news and the new suggestion. I will investigate the work required to add a “full word” parameter and post an update here when I have more information.

    Thread Starter bart85

    (@bart85)

    Great, thank you very much for the support and for creating and maintaining the plugin !
    I’m looking forward to have a “full word” parameter added if possible.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the kind words and for your patience. I did some research and made some progress.

    For the [mla_gallery] “Keyword(s) Search”, WordPress handles the search logic for all of the fields except “terms”, which is handled by MLA. For the “Taxonomy Term(s) Keyword Search”, MLA handles the entire search. That makes it possible to ass a whole_word feature to the terms search but, sadly, not for the other search fields such as Title and Description.

    I have uploaded a new MLA Development Version dated 20191223 that includes the new whole_word=true shortcode parameter. You can find step-by-step instructions for using the Development Version in this earlier topic:

    PHP Warning on media upload with Polylang

    After you install the Development version you can add whole_word=true to your shortcode parameters. This has the same effect as putting quotes around each separate word in the search text. You can still put quotes around multi-word portions of the search text to require matching the words in sequence.

    I still have some work to do to add this new option to the “Terms Search” popup window on the Media/Assistant admin submenu.

    It would be great if you can install and test the Development Version, then let me know how it works for your application. Thanks for inspiring this MLA enhancement.

    Thread Starter bart85

    (@bart85)

    Hi David,

    Perfect ! I installed and tested the Development Version and it works exactly how I want it.
    For me it doesn’t matter it doesn’t work for fields like title and description. I’m only using the terms search, because I’m using it to search photos (of which I mapped the keywords to the attachment tags field) and the title or description fields don’t have any other useful information than already available as keywords.
    Searching without the “whole word” option gave me too many photos which had nothing to do with the searched keyword. For example searching for “ant” would give me all photos of ants but also photos of a praying m

      ant

    is, not really the same thing.

    Thanks for implementing this option so quickly in the Development Version.
    Merry Christmas !

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Search only for keywords in Att.Tags’ is closed to new replies.