• Resolved fschaar

    (@fschaar)


    Hi,

    I’m trying to do something, that seemed very simple, but didnt get it to work:
    I have have in my library midi files, mp3 files, immages and pdfs. additionally to the mime type i categorized those files with midi, mp3 and so on.
    And they are actegorized with “tenor” “alt”, “sopran” etc.
    Now I want to display all files that are in the category “midi” and “tenor” for example in a gallery.
    I used this shortcode:

    [mla_gallery post_mime_type=all mla_caption="{+title+}" tax_query=array(array('taxonomy'='attachment_category','field'='slug','terms'='tenor'),array('taxonomy'='attachment_category','field'='slug','terms'='midi'),'relation'='AND')]

    The result has nothing to do with what i wanted. Also the files are not downloadable directly. I have to click on the link again.

    Any hint how to accomplish that? Shouldn’t be so difficult.

    Thanks in advance!

    • This topic was modified 6 years, 10 months ago by fschaar.

    The page I need help with: [log in to see the link]

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

    (@dglingren)

    Thanks for your question and for including the full source text of your shortcode; very helpful. A few syntax adjustments should solve your problem. Try something like this:

    
    [mla_gallery]
    post_mime_type=all
    mla_caption="{+title+}" 
    tax_query="array(
    array('taxonomy'=>'attachment_category','field'=>'slug','terms'=>'tenor'),
    array('taxonomy'=>'attachment_category','field'=>'slug','terms'=>'midi'),
    'relation'=>'AND')"
    [/mla_gallery]
    

    I’ve made the following changes:

    1. Added a “greater than” character to the array element specifications. The equals sign does not work in this context because PHP does not allow it.
    2. Added double quotes around the tax_query value. Without them the shortcode parser stops at the first space in the query specification.
    3. Changed to the alternate “enclosing shortcode” syntax, because WordPress does not process “greater than” characters within shortcode parameters.

    The enclosing shortcode syntax also lets you break long parameters over several lines to improve readability.

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

    Thread Starter fschaar

    (@fschaar)

    Thanks for giving clarity. The Examples in your docs look differently maybe there is something wrong?

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update confirming my suggested changes. You wrote “The Examples in your docs look differently … ” I reviewed the examples given in the ‘ Taxonomy Queries, the “tax_query” ‘ section of the Settings/Media Library Assistant Documentation tab and they look like the example I posted in this topic. Perhaps you are referring to another example somewhere else in the Documentation tab or in an earlier support topic. If you can give me more information I am always interested in correcting errors and improving the Documentation. Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Query midi files of certain category’ is closed to new replies.