• Resolved feelee

    (@feelee)


    Hi David,
    thanks for the great plugin, the continuous hard work and tremendous support. All this is greatly appreciated.

    I have been using the plugin for a few years now. The amount of images on my site has now grown to the hundreds of thousands and as a?result I’ve recently been running into the 504 time-out issue as others have, before me.

    After searching the forum I learned about the?“MLA Tax Query Example” plugin.?I installed it and activated it and have tried adapting my existing shortcodes to make it work. Unfortunately, after playing with it and looking at the examples I found on the forum, I’m still unable to replicate the galleries I was generating before…I was therefore hoping you could take a look at the kind of shortcode I was using before and hopefully give me some pointers on how to adapt it to make it work using the?my_custom_sql parameter.

    So, here is an example of my current shortcode:?

    [mla_gallery attachment_category="shoes" attachment_tag="galleries-sneakers,fw19-20" tax_operator=AND mla_target="_blank" link=file, full orderby=date order=DESC posts_per_page=200]
    [mla_gallery attachment_category="shoes" attachment_tag="galleries-sneakers,fw19-20" tax_operator=AND posts_per_page=200 mla_output=paginate_links]

    I’ll try to explain my use case. I have a media library with attachment_categories such as: shoes, bags, accessories, store windows… And then I have a few dozen attachment_tags such as: year, month, season (e.g. fw19-20), type of shoes (e.g. sneakers, boots, etc.), and so on.

    When I generate a gallery, I might want to output something like: FW19/20 Sneakers (which I get by using a shortcode that includes: category=shoes, tags=fw19-20,sneakers tax_operator=AND)(actually, the category=shoes is redundant and can be omitted while still getting the same result).

    Now, I’ve been trying to replicate the above shortcode in many different ways using the?“MLA Tax Query Example” plugin but, as far as I understand, it can only accept ONE taxonomy=… argument, which means (please correct me if I’m wrong on this) I cannot use tax_operator=AND in order to query the images that are assigned BOTH tag=fw19-20 AND tag=sneakers.

    I could achieve my desired outcome if I assigned a combined tag (e.g. sneakers-fw19-20) to the images I want to include in a gallery (so that I could then use attachment_tag=sneakers-fw19-20), but that would not be an ideal solution in my opinion.

    I hope I was able to explain my problem clearly enough and I would greatly appreciate your input on this.

    Thanks again!
    Regards
    Filippo

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

    (@dglingren)

    Thank you for your kind words, your question and for the detailed explanation of your application; very helpful.

    The “MLA Tax Query Example” plugin achieves its performance gains by simplifying the query that populates the gallery. In particular, it uses a simple query on the term_relationships table to get term assignments to Media Library items. I cannot think of a way to generate a simple query for general multi-taxonomy queries, e.g.:

    • attachment_category=”shoes” AND attachment_tag=”galleries-sneakers OR fw19-20″
    • attachment_category=”shoes OR boots” OR attachment_tag=”galleries-sneakers AND fw19-20″

    However, the existing query logic can be expanded to handle queries such as:

    • (attachment_category=”shoes”) AND (attachment_tag=”galleries-sneakers”) AND (attachment_tag=”fw19-20″)
    • (attachment_category=”shoes”) OR (attachment_category=”boots”) OR (attachment_tag=”galleries-sneakers) OR (attachment_tag=”fw19-20″)

    In other words, take each term assignment individually and connect the assignments by “AND” or “OR’. Really, the only case that makes sense is the first example using AND. The second example would display ALL of the shoes, ALL of the boots, ALL of the galleries-sneakers and ALL of the fw19-20.

    You wrote “(actually, the category=shoes is redundant and can be omitted while still getting the same result).” That avoids the multiple taxonomy issue and just requires attachment_tag=”galleries-sneakers AND fw19-20″; a subset of the expanded query.

    If that makes sense I can work on implementing the extension. I can’t promise a delivery date but I will do what I can. Let me know if you want to proceed, and thanks for your continued interest in the plugin as well as this interesting idea.

    Thread Starter feelee

    (@feelee)

    Thanks for your reply David. Very kind and generous, as always.

    I don’t know how much trouble it would be for you to work on coding your proposed solution. Obviously I would find that extremely useful.

    But, I could also “spare” you the trouble if I was able to output a general gallery (which would include ALL shoes, or all shoes tagged as “FW19-20-shoes”) and then offer the user the possibility of further filtering such gallery by many other parameters (att_tags such as fw19-20, boots, sneakers…).

    I’m pretty sure that this is possible, and I have been trying hard to find the right way to do it by reading the forum, the plugin’s documentation and going through some of the example plugins. Unfortunately my currently-still-limited technical knowledge of wp and basic coding has prevented me thus far from finding such solution…but I intend on persevering.

    In the meantime, if you had any pointers on how to go about this second way of approaching the problem, I would again be very grateful.

    Thank you.
    Filippo

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the positive feedback and for sharing your “general gallery’ idea. I decided that extending the MLA Tax Query Example plugin might be of general interest (and it was an interesting challenge) so I proceeded with my development.

    I am open to pursuing your general gallery idea if you still need it, but it would be best to open a new support topic for that.

    I have uploaded a new MLA Development Version dated 20191217 that includes the updated example plugin. You can find step-by-step instructions for using the Development Version in this earlier topic:

    PHP Warning on media upload with Polylang

    Once the Development Version is installed you must update and verify the example plugin. Navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “Tax Query” in the text box and click “Search Plugins” to filter the table.

    You are looking for the “MLA Tax Query Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “Update” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and verify the example plugin as you would any other plugin. Make sure you have the latest version, 1.10, installed.
    Once the Development Version and updated example plugin are installed and active you can go back to your application page and modify the shortcodes to use the new feature.

    Here is an updated version of your example that works on my test system:

    [mla_gallery my_custom_sql='attachment_category="shoes" attachment_tag="galleries-sneakers,fw19-20" tax_operator=AND' mla_target="_blank" link=file, full orderby=date order=DESC posts_per_page=200]
    [mla_gallery my_custom_sql='attachment_category="shoes" attachment_tag="galleries-sneakers,fw19-20" tax_operator=AND' posts_per_page=200 mla_output=paginate_links]
    

    As you can see, I simply added my_custom_sql=' before the first taxonomy parameter and added a closing single quote after the tax_operator=AND parameter.

    I hope the changes and the updated plugin will give you the results you need. I will leave this topic unresolved in case you have problems or further questions regarding the above suggestions.

    Thread Starter feelee

    (@feelee)

    Thank you so much David!
    Your solution works perfectly!
    As far as I’m concerned, you can close this topic and consider it resolved.

    I’m also still interested in exploring the other solution (full gallery + filters), but I understand I will need to open a new support topic for that one.

    In the meantime, thank you again and I wish you a good day!

    Plugin Author David Lingren

    (@dglingren)

    Thanks for installing the updated example plugin and reporting the good new that it’s working for your application.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding the tax_operator feature. Thanks for working with me on this MLA enhancement.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘“MLA Tax Query Example” plugin syntax’ is closed to new replies.