WordPress
get_bloginfo ()
수색…
소개
현재 사이트에 대한 정보를 검색합니다.
통사론
- get_bloginfo ($ show, $ filter)
매개 변수
매개 변수 | 세부 |
---|---|
$ 쇼 | (문자열) 검색 할 사이트 설정 정보입니다. |
$ filter | (문자열) 필터링 된 값을 반환할지 여부에 대한 지정입니다. |
비고
$ 쇼
값 | 기술 | 예 |
---|---|---|
'이름'(기본값) | 사이트 제목 | 'Matt Mullenweg' |
'기술' | 사이트 태그 라인 | 'Just another WordPress site' |
'wpurl' | WordPress 설치 URL입니다. site_url() 함수와 동일 | 'http://example.com' , 'http://localhost/wordpress' |
'url' | 사이트의 URL. home_url() 함수와 동일합니다. | 'http://example.com' , 'http://localhost/wordpress' |
'admin_email' | 기본 관리자의 이메일 주소 | '[email protected]' |
'charset' | 페이지 및 피드의 문자 인코딩 | 'UTF-8' |
'번역' | 현재 WordPress 설치 버전 | '4.5' |
'html_type' | HTML의 content-type 값 | 'text/html' |
'text_direction' | 사이트 언어에 따라 결정되는 텍스트 방향 | 'ltr' |
'언어' | ISO 639-1 기반 언어 코드 | 'en-US' |
'stylesheet_url' | 활성화 된 테마의 스타일 시트 URL입니다. 가치 우선 순위 : 하위 테마 »상위 테마. | 'http://example.com/wp-content/themes/twentysixteen/style.css' |
'stylesheet_directory' | 활성화 된 테마의 자원 위치. 가치 우선 순위 : 하위 테마 »상위 테마. | 'http://example.com/wp-content/themes/twentysixteen' |
'template_url' | 활성화 된 테마의 URL 디렉토리. 가치 우선 순위 : 부모 테마 »자녀 테마. | 'http://example.com/wp-content/themes/twentysixteen' |
'template_directory' | 'template_url' 과 동일 | |
'pingback_url' | Pingback XML-RPC 파일 | 'http://example/xmlrpc.php' |
'atom_url' | Atom 피드 URL | 'http://example/feed/atom/' |
'rdf_url' | RDF / RSS 1.0 피드 URL | 'http://example/feed/rdf/' |
'rss_url' | RSS 0.92 피드 URL | 'http://example/feed/rss/' |
'rss2_url' | RSS 2.0 피드 URL | 'http://example/feed/' |
'comments_atom_url' | 댓글 Atom 피드 URL | 'http://example/comments/feed/atom/' |
'siteurl' | (사용 중지됨) 대신 'url'사용 | |
'집' | (사용 중지됨) 대신 'url'사용 |
$ filter
값 | 기술 | 예 |
---|---|---|
'raw'(기본값) | 필터가 적용되지 않습니다. | 원시 데이터 |
'디스플레이' | $show 가 'url' , 'directory' , 'home' 이 아닌 경우 필터는 반환 값에 적용됩니다. | 필터링 된 데이터 |
사이트 제목 얻기
<?php echo get_bloginfo( 'name' ); ?>
또는
<?php echo get_bloginfo(); ?>
산출
Matt Mullenweg
이 샘플 설정을 기반으로
사이트 태그 라인 얻기
<?php echo get_bloginfo( 'description' ); ?>
산출
Just another WordPress site
이 샘플 설정을 기반으로
활성 테마 URL 얻기
<?php echo esc_url( get_bloginfo( 'stylesheet_directory' ) ); ?>
산출
http://example.com/wp-content/themes/twentysixteen
대안
내부적으로 get_bloginfo( 'stylesheet_directory' )
호출 get_stylesheet_directory_uri()
대신 것을 사용할 수 있도록 :
<?php echo esc_url( get_stylesheet_directory_uri() ); ?>
많은 개발자는 get_bloginfo()
와 명명 규칙이 일치하지 않기 때문에 이러한 전용 함수를 사용하는 것을 선호합니다. 예를 들어, get_stylesheet_directory()
는 자식 테마 경로를 반환합니다. 그러나 이전 예에서 설명한 get_bloginfo( 'stylesheet_directory' )
는 하위 테마 URL을 반환합니다. 대신 get_stylesheet_directory_uri()
를 사용하면 경로 또는 URL을 검색하는지 혼동 할 가능성이 줄어 듭니다.
사이트 URL 가져 오기
<?php echo esc_url(get_bloginfo('url')); ?>
또는 하위 페이지에 링크해야하는 경우
<?php echo esc_url(get_bloginfo('url') . '/some-sub-page'); ?>
사이트 관리자의 이메일 주소 받기
get_bloginfo
함수를 사용하여 사이트 관리자의 전자 메일 주소를 검색 할 수 있습니다.
<?php echo get_bloginfo('admin_email'); ?>
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow