나는이 기사를 읽었습니다 : 일반적인 WordPress 개발 실수 및 해결 방법 , 저자는 말합니다 :
테마 위치 가져 오기 : TEMPLATEPATH 또는 bloginfo ( 'template_directory')를 사용중인 경우. 중지! 위의 예제에서 볼 수 있듯이 매우 유용한 get_template_directory ()를 사용해야합니다.
그러나 그는 정교하지 않습니다. 뭐가 그렇게 나쁜 bloginfo()
거야?
나는이 기사를 읽었습니다 : 일반적인 WordPress 개발 실수 및 해결 방법 , 저자는 말합니다 :
테마 위치 가져 오기 : TEMPLATEPATH 또는 bloginfo ( 'template_directory')를 사용중인 경우. 중지! 위의 예제에서 볼 수 있듯이 매우 유용한 get_template_directory ()를 사용해야합니다.
그러나 그는 정교하지 않습니다. 뭐가 그렇게 나쁜 bloginfo()
거야?
답변:
긴 이야기를 짧게 만들려면 다음 get_bloginfo( 'template_directory' )
과 get_bloginfo( 'template_url' )
단순히 반환 get_template_directory_uri()
.
따라서 후자의 템플릿 태그를 직접 참조하여 두 번째 통화를 바로 가기로 할 수 있습니다.
에 대한 소스를 참조하십시오get_bloginfo()
.
다른 몇 가지 :
'url'
=> home_url()
'wpurl'
=> site_url()
'stylesheet_url'
=> get_stylesheet_uri()
'stylesheet_directory'
=> get_stylesheet_directory_uri()
'locale'
=> get_locale()
참고 사항 : TEMPLATEPATH
및 STYLESHEETPATH
deprecation 용으로 예정 되어 있으므로 현재 get_template_directory()
및 get_stylesheet_directory()
로 각각 교체하는 것이 좋습니다 .
다시 :이 의견
내가 말하려고했던 것 :).
get_template_directory()
경로와get_template_directory_uri()
URL 을 반환하는 것을 추가하고 싶습니다 . 그래서 저자는 일관되지 않는 :get_bloginfo( 'template_directory' )
그리고get_template_directory()
다른 일을 반환!
다시 소스를 참조하십시오 :)
case 'template_directory':
case 'template_url':
$output = get_template_directory_uri();
break;
다시 :이 의견 :
자식 테마를 개발할 때주의해야 할 점은
get_stylesheet_directory()
명시 적으로 사용해야 합니다. 내가 틀렸다면 누군가 나를 교정합니다.
사실이지만 항상 그렇습니다. get_bloginfo()
반환하지 않습니다 어떤 관련을 get_stylesheet_directory()
. get_stylesheet_uri()
and 만 반환합니다 get_stylesheet_directory_uri()
.
get_bloginfo()
매개 변수 와의 호환성을 유지하기위한 것이라고 생각합니다 .