Wordpress 테마를 조정하고 초점이 맞춰진 검색 필드를 지우려고하지만 다음 코드를 추가하면 흰색 화면이 나타납니다. 빈 onfocus = ""명령으로이 PHP 스크립트를 실행하면 모든 것이 정상이기 때문에 실제 자바 스크립트 함수는 그것을 죽이는 것 같습니다.
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
function add_search_box($items, $args) {
if( $args->theme_location == 'primary' ) {
$items .= '<li id="omc-header-search">
<span id="omc-search-overlay">'. __('Search', 'gonzo') .' →</span>
<form method="get" id="desktop-search" class="omc-search-form" action="'.get_bloginfo('url').'/">
<input type="text" class="omc-header-search-input-box" value="Search" onfocus="if(this.value == 'Default text') { this.value = ''; }" name="s" id="fffff">
<input type="submit" class="omc-header-search-button" id="searchsubmit" value="">
</form>
</li>';
return $items;
}
나는 이것이 왜 전체가 충돌을 일으키는 지 전혀 모른다.
흰색 페이지는 일반적으로 PHP 치명적인 오류 또는 구문 오류를 나타냅니다.
이 경우 몇 가지 다른 오류가 있습니다.
{
당신의에서 if()
문'
제대로 이스케이프되지 않은 따옴표가 포함되어 있습니다.또한 필드의 기본 텍스트가 일치하지 않습니다.
"Search"
있습니다value="Search"
"Default text"
입니다.PHP 구문 오류를 수정하고로 업데이트 Default text
하면 Search
작동합니다.
이렇게 :
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
function add_search_box($items, $args) {
if( $args->theme_location == 'primary' ) {
$items .= '<li id="omc-header-search">
<span id="omc-search-overlay">'. __('Search', 'gonzo') .' →</span>
<form method="get" id="desktop-search" class="omc-search-form" action="'.get_bloginfo('url').'/">
<input type="text" class="omc-header-search-input-box" value="Search" onfocus="if(this.value == \'Search\') { this.value = \'\'; }" name="s" id="fffff">
<input type="submit" class="omc-header-search-button" id="searchsubmit" value="">
</form>
</li>';
}
return $items;
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다