I have a category dropdown within my searchform.php, coding within Wordpress 4.x. It has worked without issue for a couple of years.
An issue has arisen with Wordpress 5.2.
My searchform.php
includes a modified form for the search and a dropdown menu for categories using wp_dropdown_categories()
.
get_search_form()
outputs nothing.
A précis of searchform.php
;
<div>
$args = array (
...some arguments...
);
wp_dropdown_categories($args);
<form>... search code
...</form>
if I remove wp_dropdown_categories()
and insert it in the calling page before get_search_form()
it works perfectly.
There are no PHP errors or warnings.
Whereas separating the two function calls is no problem, I am curious as to what might be happening and under what circumstances get_search_form()
can fail without returning any error.
I have a category dropdown within my searchform.php, coding within Wordpress 4.x. It has worked without issue for a couple of years.
An issue has arisen with Wordpress 5.2.
My searchform.php
includes a modified form for the search and a dropdown menu for categories using wp_dropdown_categories()
.
get_search_form()
outputs nothing.
A précis of searchform.php
;
<div>
$args = array (
...some arguments...
);
wp_dropdown_categories($args);
<form>... search code
...</form>
if I remove wp_dropdown_categories()
and insert it in the calling page before get_search_form()
it works perfectly.
There are no PHP errors or warnings.
Whereas separating the two function calls is no problem, I am curious as to what might be happening and under what circumstances get_search_form()
can fail without returning any error.
- ps if anyone can think of a clearer title, please feel free – Chris Pink Commented Jul 1, 2019 at 9:34
- Can you share the full code of searchform.php? – Jacob Peattie Commented Jul 1, 2019 at 9:40
1 Answer
Reset to default 0It turns out the use of a variable called $args within 'searchform.php' causes the searchform to output nothing.