[英]Parse error: syntax error, unexpected 'search' (T_STRING)
Hi guys I new to this and I'm trying to create a search form, but seems to be a problem with my function php file. 嗨,大家好,我是新来的,我正在尝试创建一个搜索表单,但是我的函数php文件似乎有问题。 I know for fact that the problem is in my "if" statement but I have no clue if there's any other option that i could use to make it work.
我实际上知道问题出在我的“ if”语句中,但是我不知道是否还有其他选择可以使它起作用。 Here's the code:
这是代码:
function my_search_form( $form ) {
$form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
<input type="text" name="s" id="search" align="center" size="30" value="' . get_searchform() . '" onfocus="if(this.value == . 'search & hit enter' . ) { this.value = . '' . ; }" onblur="if(this.value == . '' . ) {this.value = . 'search & hit enter' . ; }" />
<input type="hidden" value="post" name="post_type" id="post_type" />
</form>';
return $form;
} }
add_filter( 'get_search_form', 'my_search_form' );
search & hit enter
This part is invalid code, it needs to be escaped 这部分是无效代码,需要转义
function my_search_form( $form ) {
$form = '
<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
<input type="text" name="s" id="search" align="center" size="30" value="' . get_searchform() . '" onfocus="if(this.value == \'search & hit enter\') { this.value = \'\'; }" onblur="if(this.value == \'\') {this.value =\'search & hit enter\'; }" />
<input type="hidden" value="post" name="post_type" id="post_type" />
</form>';
return $form;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.