• Resolved onealklea

    (@onealklea)


    Please help me understand why this code is not working any more. I’m guessing an update may have caused the problem because code hasn’t changed. I added the debug code below as well as the regular code.

    <form id="attachment-category-form" method="get" action="/audio-archives/">
            <select name="category_value" class="postform">
    		<option value="">-- All Topics --</option>
                    <option value="bible-studies">Bible Studies</option>
                    <option value="joyful-life">Joyful Life</option>
    		<option value="life-giving-homeschool-hints">Life-giving Homeschool Hints</option>
    		<option value="life-giving-moment-about-marriage">Life-giving Moment About Marriage</option>
    		<option value="life-giving-motherhood-moments">Life-giving Motherhood Moments</option>
                    <option value="legacy-of-faith">Living a Legacy of Faith</option>
                    <option value="own-your-life">Own Your Life</option>
                    <option value="parenting">Parenting</option>
    	</select> <input type="text" id="mla-search-box" name="search-string" value="" placeholder="Keyword Search"> <input type="submit" id="submit" name="submit" value="GO">
    </form>
    [mla_gallery my_custom_audio="" orderby="title" post_mime_type="audio/mpeg" category="subscription" s="{+request:search-string+}" attachment_category="{+request:category_value+}"   mla_caption="<hr align=center noshade width=25%><br /><br /><br /><h4>{+title+}</h4> <strong>Topic: </strong>{+terms:attachment_category+}<br /><strong>Scripture:</strong> {+caption+}<br /><br /><strong>Description: </strong>{+description+}<br />" link=file mla_target="_blank" columns=1 posts_per_page=7 mla_debug=true]
    [mla_gallery orderby="title" post_mime_type="audio/mpeg" category="subscription" s="{+request:search-string+}" attachment_category="{+request:category_value+}" mla_caption="<hr align=center noshade width=25%><br /><br /><br /><h4>{+title+}</h4> <strong>Topic: </strong>{+terms:attachment_category+}<br /><strong>Scripture:</strong> {+caption+}<br /><br /><strong>Description:</strong> {+description+}<br />" link=file columns=1 posts_per_page=7 mla_output="paginate_links,prev_next" mla_debug=true]
    mla_debug empty gallery, query = array ( 'my_custom_audio' => '', 'orderby' => 'title', 'post_mime_type' => 'audio/mpeg', 'category' => 'subscription', 's' => '', 'attachment_category' => '', 'mla_caption' => '
    
    {+title+}
    
    Topic: {+terms:attachment_category+}
    Scripture: {+caption+}
    
    Description: {+description+}
    ', 'link' => 'file', 'mla_target' => '_blank', 'columns' => '1', 'posts_per_page' => '7', 'mla_debug' => 'true', 'mla_page_parameter' => 'mla_paginate_current', )
    
    mla_debug $wp_filter[posts_where] priority = 10
    filter name = 'powerpress_posts_where'
    
    mla_debug $wp_filter[posts_where] priority = 2147483647
    filter name = 'MLAShortcodes::mla_shortcode_query_posts_where_filter'
    
    mla_debug $wp_filter[posts_orderby] priority = 2147483647
    filter name = 'MLAShortcodes::mla_shortcode_query_posts_orderby_filter'
    
    mla_debug WHERE filter = ' AND ( wp_term_relationships.term_taxonomy_id IN (379) AND 0 = 1 ) AND (wp_posts.post_mime_type = \'audio/mpeg\') AND wp_posts.post_type = \'attachment\' AND (((wp_posts.post_status = \'inherit\') OR (wp_posts.post_status = \'inherit\' AND (p2.post_status = \'inherit\'))))'
    
    mla_debug modified WHERE filter = ' AND ( wp_term_relationships.term_taxonomy_id IN (379) AND 0 = 1 ) AND (wp_posts.post_mime_type = \'audio/mpeg\') AND wp_posts.post_type = \'attachment\' AND (((wp_posts.post_status = \'inherit\') OR (wp_posts.post_status = \'inherit\' AND (p2.post_status = \'inherit\'))))'
    
    mla_debug ORDER BY filter, incoming = 'wp_posts.post_date DESC'
    Replacement ORDER BY clause = 'wp_posts.post_title ASC'
    
    mla_debug posts_clauses filter = array ( 'where' => ' AND ( wp_term_relationships.term_taxonomy_id IN (379) AND 0 = 1 ) AND (wp_posts.post_mime_type = \'audio/mpeg\') AND wp_posts.post_type = \'attachment\' AND (((wp_posts.post_status = \'inherit\') OR (wp_posts.post_status = \'inherit\' AND (p2.post_status = \'inherit\'))))', 'groupby' => 'wp_posts.ID', 'join' => ' INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_posts AS p2 ON (p2.ID = p2.ID) ', 'orderby' => 'wp_posts.post_title ASC', 'distinct' => '', 'fields' => 'wp_posts.*', 'limits' => 'LIMIT 0, 7', )
    
    mla_debug posts_clauses_request filter = array ( 'where' => ' AND ( wp_term_relationships.term_taxonomy_id IN (379) AND 0 = 1 ) AND (wp_posts.post_mime_type = \'audio/mpeg\') AND wp_posts.post_type = \'attachment\' AND (((wp_posts.post_status = \'inherit\') OR (wp_posts.post_status = \'inherit\' AND (p2.post_status = \'inherit\'))))', 'groupby' => 'wp_posts.ID', 'join' => ' INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_posts AS p2 ON (p2.ID = p2.ID) ', 'orderby' => 'wp_posts.post_title ASC', 'distinct' => '', 'fields' => 'wp_posts.*', 'limits' => 'LIMIT 0, 7', )
    
    mla_debug query = array ( 'tax_query' => array ( 'relation' => 'AND', 0 => array ( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array ( 0 => 'subscription', ), 'operator' => 'IN', 'include_children' => true, ), 1 => array ( 'taxonomy' => 'attachment_category', 'field' => 'slug', 'terms' => array ( 0 => '', ), 'operator' => 'IN', 'include_children' => true, ), ), 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_mime_type' => 'audio/mpeg', 'posts_per_page' => 7, 'ignore_sticky_posts' => true, 'no_found_rows' => true, )
    
    mla_debug request = 'SELECT wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_posts AS p2 ON (p2.ID = p2.ID) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (379) AND 0 = 1 ) AND (wp_posts.post_mime_type = \'audio/mpeg\') AND wp_posts.post_type = \'attachment\' AND (((wp_posts.post_status = \'inherit\') OR (wp_posts.post_status = \'inherit\' AND (p2.post_status = \'inherit\')))) GROUP BY wp_posts.ID ORDER BY wp_posts.post_title ASC LIMIT 0, 7'
    
    mla_debug query_vars = array ( 'tax_query' => array ( 'relation' => 'AND', 0 => array ( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array ( 0 => 'subscription', ), 'operator' => 'IN', 'include_children' => true, ), 1 => array ( 'taxonomy' => 'attachment_category', 'field' => 'slug', 'terms' => array ( 0 => '', ), 'operator' => 'IN', 'include_children' => true, ), ), 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_mime_type' => 'audio/mpeg', 'posts_per_page' => 7, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'error' => '', 'm' => '', 'p' => 0, 'post_parent' => '', 'subpost' => '', 'subpost_id' => '', 'attachment' => '', 'attachment_id' => 0, 'name' => '', 'static' => '', 'pagename' => '', 'page_id' => 0, 'second' => '', 'minute' => '', 'hour' => '', 'day' => 0, 'monthnum' => 0, 'year' => 0, 'w' => 0, 'category_name' => 'subscription', 'tag' => '', 'cat' => 263, 'tag_id' => '', 'author' => '', 'author_name' => '', 'feed' => '', 'tb' => '', 'paged' => 0, 'comments_popup' => '', 'meta_key' => '', 'meta_value' => '', 'preview' => '', 's' => '', 'sentence' => '', 'fields' => '', 'menu_order' => '', 'category__in' => array ( ), 'category__not_in' => array ( ), 'category__and' => array ( ), 'post__in' => array ( ), 'post__not_in' => array ( ), 'tag__in' => array ( ), 'tag__not_in' => array ( ), 'tag__and' => array ( ), 'tag_slug__in' => array ( ), 'tag_slug__and' => array ( ), 'post_parent__in' => array ( ), 'post_parent__not_in' => array ( ), 'author__in' => array ( ), 'author__not_in' => array ( ), 'suppress_filters' => false, 'cache_results' => true, 'update_post_term_cache' => true, 'update_post_meta_cache' => true, 'nopaging' => false, 'comments_per_page' => '50', 'order' => 'DESC', )
    
    mla_debug post_count = 0

    https://www.ads-software.com/plugins/media-library-assistant/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter onealklea

    (@onealklea)

    I found one problem. category=subscription was not displaying anything so I changed it to categories=subscription instead and now it is displaying all the audio with “subscription” as their category. The search is also working fine but the select a topic isn’t working. Wondering if attachment category term is correct.

    Thread Starter onealklea

    (@onealklea)

    Fixed. Someone changed the slugs on the categories and now all working. So, “category” term is now called “categories” in new WordPress update.

    Plugin Author David Lingren

    (@dglingren)

    Our messages crossed in the ether. Here is my response to your first message. Let me know if you have any further problems…

    Thanks for your question; I regret the issue you are having with your multiple taxonomy query. Thanks as well for posting the regular code and the debug results, which are very helpful.

    First, I suggest you go back to the original category=subscription parameter; category is the correct “slug” for the “Categories” taxonomy. Your alternative parameter, categories=subscription is simply ignored.

    Second, let me make sure I understand what results you want from your shortcodes. I am guessing that you want to select the items that have category=subscription OR items that have attachment_category="{+request:category_value+}". In other words, a match on either one of the two taxonomy filters should be accepted. Is that right?

    Finally, the s="{+request:search-string+}" parameter will further restrict/filter the results, if entered. Items must match the taxonomy filters in addition to matching the search string. Is that right?

    The current MLA version, v1.95, includes two changes that probably account for the issue you are now having:

    • New: A “tax_relation” parameter has been added for [mla_gallery] simple taxonomy searches that involve two or more taxonomies.
    • Fix: For [mla_gallery] simple taxonomy searches that involve two or more taxonomies are now processed correctly.

    The “Fix:” change is probably the old version seemed to work and no longer seems to work with the new version. In fact, older MLA versions did not process queries on both category and attachment_category correctly.

    The default connector when two taxonomies are used is “AND”, which means that an item would have to match both category=subscription AND whatever attachment_category value selected. When “– All Topics –” is selected there is no matching term in attachment_category and the query will not return any matching items. That’s the “AND 0 = 1” clause you can see in the debug results.

    The “New:” change will probably fix the problem. If you add tax_relation=OR to both of your [mla_gallery] shortcodes you will get items that match either (or both) of the taxonomy selections.

    Make both of the suggested changes and let me know if you get better results. I will leave this topic unresolved until I hear back from you.

    Thread Starter onealklea

    (@onealklea)

    Ah ha! I added tax_relation=OR and it will display all fine but when I choose a particular Attachment Category then it still displays all. I really want “AND” but when someone chooses a particular Attachment Category then it only displays that particular Attachment Category as long as the category is “subscription”

    Plugin Author David Lingren

    (@dglingren)

    Thanks for going through my response and for trying the tax_relation parameter. The way database queries use “AND” and “OR” is different than the way people use “AND” when describing what they want, and I want to make sure I understand the results you want. When you say ‘ I really want “AND” ‘ do you mean:

    • I want the items that have both category=subscription AND the “particular Attachment Category”

    or do you mean:

    • I want the items that have either category=subscription OR the “particular Attachment Category”

    Does that make sense? When you say ‘ it only displays that particular Attachment Category as long as the category is “subscription” ‘ you are describing the “AND” logic; the first alternative above.

    Either way, it sounds like the tax_relation parameter may not be working. It would be very helpful if you could re-post your current code and the debug results.

    Once I understand what you want to achieve I can do some more investigation. Thanks for your patience and persistence in working through this issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Search isn't displaying now but nothing was changed in code’ is closed to new replies.