0

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 Jul 1 '19 at 9:34
  • Can you share the full code of searchform.php? – Jacob Peattie Jul 1 '19 at 9:40
0

It turns out the use of a variable called $args within 'searchform.php' causes the searchform to output nothing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.