最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

search - searchform.php not included by get_search_form when using wp_dropdown_categories

programmeradmin1浏览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.

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.

Share Improve this question edited Jul 1, 2019 at 10:41 Chris Pink asked Jul 1, 2019 at 9:33 Chris PinkChris Pink 7521 gold badge6 silver badges21 bronze badges 2
  • 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
Add a comment  | 

1 Answer 1

Reset to default 0

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

发布评论

评论列表(0)

  1. 暂无评论