{"id":12194209,"date":"2019-12-01T20:05:12","date_gmt":"2019-12-01T20:05:12","guid":{"rendered":"https:\/\/wordpress.org\/support\/?post_type=topic&#038;p=12194209"},"modified":"2019-12-01T20:08:31","modified_gmt":"2019-12-01T20:08:31","slug":"custom-dropdown-not-appearing-in-ajax-request","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/custom-dropdown-not-appearing-in-ajax-request\/","title":{"rendered":"custom dropdown not appearing in ajax request"},"content":{"rendered":"<p>Hello,<br \/>\nI&#8217;m trying to add a tags dropdown to the search which allows user to search by post_tags. I have added my own custom template, added the dropdown, added the wpsl-custom-dropdown class to the select tag. When i submit the search form there is no value for my dropdown appearing in the network tab of chrome dev tools. Here is the relevant code:<\/p>\n<p>functions.php:<br \/>\nfunction custom_map_tag_menu() {<br \/>\n    $tags_array = get_tags( $args );<br \/>\n    \/\/ var_dump($tags_array);die;<br \/>\n    $html = &#8221;;<br \/>\n    $html .= &#8216;&lt;div id=&#8221;wpsl-tags&#8221;&gt;&#8217;;<br \/>\n    $html .= &#8216;&lt;label for=&#8221;wpsl-tags-list&#8221;&gt;Tags filter&lt;\/label&gt;&#8217;;<br \/>\n    $html .= &#8216;&lt;div class=&#8221;wpsl-dropdown&#8221;&gt;&#8217;;<br \/>\n    $html .= &#8216;&lt;select name=&#8221;wpsl-tags&#8221; id=&#8221;wpsl-tags-list&#8221; class=&#8221;wpsl-custom-dropdown&#8221; style=&#8221;display: none;&#8221;&gt;&#8217;;<br \/>\n    $html .= &#8216;&lt;option value=&#8221;0&#8243;&gt;Any&lt;\/option&gt;&#8217;;<br \/>\n    if(!empty($tags_array)){<br \/>\n        foreach ($tags_array as $tag) {<br \/>\n            $html .= &#8216;&lt;option value=&#8221;&#8216;.$tag-&gt;term_id.'&#8221;&gt;&#8217;.$tag-&gt;name.'&lt;\/option&gt;&#8217;;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    $html .= &#8216;&lt;\/select&gt;&#8217;;<br \/>\n    $html .= &#8216;&lt;\/div&gt;&#8217;;<br \/>\n    $html .= &#8216;&lt;\/div&gt;&#8217;;<\/p>\n<p>    return $html;<br \/>\n}<\/p>\n<p>custom.php:<br \/>\n$output .= custom_map_tag_menu();<\/p>\n<p>HTML in chrome inspect window:<br \/>\n&lt;div id=&#8221;wpsl-tags&#8221;&gt;<br \/>\n&lt;label for=&#8221;wpsl-tags-list&#8221;&gt;Tags filter&lt;\/label&gt;<br \/>\n&lt;div class=&#8221;wpsl-dropdown&#8221;&gt;<br \/>\n&lt;div class=&#8221;&#8221; style=&#8221;display: none; height: 0px;&#8221;&gt;<br \/>\n&lt;select name=&#8221;wpsl-tags&#8221; id=&#8221;wpsl-tags-list&#8221; class=&#8221;wpsl-custom-dropdown&#8221; style=&#8221;display: none;&#8221;&gt;<br \/>\n&lt;option value=&#8221;0&#8243;&gt;Any&lt;\/option&gt;<br \/>\n&lt;option value=&#8221;4&#8243;&gt;Nymphs&lt;\/option&gt;<br \/>\n&lt;option value=&#8221;3&#8243;&gt;Pixies&lt;\/option&gt;<br \/>\n&lt;\/select&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;span data-value=&#8221;4&#8243; class=&#8221;wpsl-selected-item&#8221;&gt;Nymphs&lt;\/span&gt;<br \/>\n&lt;div style=&#8221;height: 0px;&#8221;&gt;<\/p>\n<ul>\n&lt;li data-value=&#8221;0&#8243;&gt;Any<\/li>\n<p>&lt;li data-value=&#8221;4&#8243; class=&#8221;wpsl-selected-dropdown&#8221;&gt;Nymphs<\/li>\n<p>&lt;li data-value=&#8221;3&#8243;&gt;Pixies<\/li>\n<\/ul>\n<p>&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<\/p>\n<p>Values in ajax call as viewed in chrome network tab:<br \/>\naction: store_search<br \/>\nlat: 53.4874254<br \/>\nlng: -2.249531700000034<br \/>\nmax_results: 25<br \/>\nsearch_radius: 50<br \/>\nfilter: 13<\/p>\n<p>&#8216;filter&#8217; refers to the default category dropdown.<\/p>\n<p>Any ideas?<\/p>\n<p>Many Thanks<\/p>\n","protected":false},"template":"","class_list":["post-12194209","topic","type-topic","status-publish","hentry","topic-tag-ajax","topic-tag-custom","topic-tag-dropdown"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12194209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12194209\/revisions"}],"predecessor-version":[{"id":12194214,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12194209\/revisions\/12194214"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12194209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}