IT분야 (IT sector)
워드프레스 (wordpress) 템플릿 함수
Sherlockhomes
2013. 7. 14. 21:16
728x90
반응형
워드프레스의 테마를 만들거나 수정하기 위해 유용하게 사용할 수 있는 템플릿 함수태그를 종류와 용도를 정리하였다.
탬플릿 호출 관련
wp_nav_menu( $args );
네비게이션 메뉴 표시
(use) http://codex.wordpress.org/Function_Reference/wp_nav_menu 참고
get_header( $name );
header.php 인클루드 태그, $name은 header-{name}.php형태로 사용함
(ex) header-front.php
get_footer( $name );
footer.php 인클루드 태그, $name은 footer-{name}.php형태로 사용함
(ex) footer-front.php
get_sidebar( $name );
sidebar.php 인클루드 태그, $name은 sidebar-{name}.php형태로 사용함
(ex) sidebar-left.php / sidebar-right.php / sidebar-footer.php
get_template_part( $slug, $name );
템플릿 파일에 템플릿 구성요소를 가져옴. $slug는 템플릿 파일을 대표하는 이름, $name 은 특정화된 이름
(ex) single.php파일에서 get_template_part( ‘content’, ’single’ )는 content-single.php파일을 가져옴
get_search_form();
검색 템플릿 태그를 가져옴
(ex) searchform.php
로그인 관련
wp_loginout( $redirect );
로그인 링크 표시. 로그인 후에는 로그아웃 표시. $redirect 는 로그인 후 보이는 페이지 설정.
(ex) wp_loginout( ‘index.php’ );는 초기화면으로 이동
echo wp_logout_url( $redirect );
로그아웃 후 링크되는 페이지 표시.
(ex) <a href=”echo wp_logout_url( home_url() );” title=”logout” Logout </a>
echo wp_login_url( $redirect );
로그인 후 링크되는 페이지 표시.
(ex) <a href=”echo wp_login_url( home_url() );” title=”login” Login </a>
echo wp_login_form( $redirect );
로그인 후 링크되는 페이지 표시.
(ex) <a href=”echo wp_login_url( home_url() );” title=”login” Login </a>
echo wp_login_form( $args );
로그인 폼을 사용하는 태그
(use) http://codex.wordpress.org/Function_Reference/wp_login_form 참고
(ex)$args = array(
'echo' => true,
'redirect' => site_url( $_SERVER['REQUEST_URI'] ),
'form_id' => 'loginform',
'label_username' => __( 'Username' ),
'label_password' => __( 'Password' ),
'label_remember' => __( 'Remember Me' ),
'label_log_in' => __( 'Log In' ),
'id_username' => 'user_login',
'id_password' => 'user_pass',
'id_remember' => 'rememberme',
'id_submit' => 'wp-submit',
'remember' => true,
'value_username' => NULL,
'value_remember' => false );
wp_register();
로그인한 경우 사이트 관리를 표시. 로그인하지 않은 경우 등록하기를 표시
설치된 워드프레스 정보 호출 관련
bloginfo( $show );
블로그의 정보 표시. $show 인자를 통해 필요 정보를 호출하여 노출.
(ex)
Name - 사이트 이름
description - 태그라인
admin_email - 관리자 이메일
url - 홈url
wpurl - 사이트 url
stylesheet_directory ? 자식 테마 디렉토리 path값
stylesheet_url ? 자식 테마 스타일시트
template_directory ? 부모 테마 디렉토리 path값
template_url ? 부모 테마 스타일시트
charset ? UTF8
html_type ? text/html
language ? ko_KR
wp_title( );
웹브라우저 상단 / 탭에 페이지 제목 표시
single_post_title();
싱글 페이지 사용 시 글 제목 표시
post_type_archive_title();
글 형식 제목 표시
single_cat_title();
현재 글 보관함 페이지의 카테고리 제목 표시
single_tag_title();
현재 글 보관함 페이지의 태그 제목 표시
single_month_title();
현재 페이지의 월/년도 제목 표시
get_calendar();
글링크가 포함된 달력 표시
the_author();
반복문에서 글쓴이 표시
the_author_link();
프로필 설정화면에 입력된 글쓴이의 url입력 부분 링크 표시
the_author_meta( $field, $userID );
사용자의 각종 정보를 불러옴. $field는 참고사이트 참조
(use) http://codex.wordpress.org/Function_Reference/the_author_meta 참고
(ex) $field : 데이터 값을 해당 필드에 보낸다
- user_login
- user_pass
- user_nicename
- user_email
- user_url
- user_registered
- user_activation_key
- user_status
- display_name
- nickname
- first_name
- last_name
- description
- jabber
- aim
- yim
- user_level
- user_firstname
- user_lastname
- user_description
- rich_editing
- comment_shortcuts
- admin_color
- plugins_per_page
- plugins_last_view
$userID : 사용자 ID 필드를 사용 하는 경우 다음 함수는 사용자 ID에 대한 특정 필드를 표시
the_author_posts();
글쓴이의 글 개수 표시
the_author_posts_link();
반복문에서 사용되며 글쓴이의 글 저장소로 링크
single_cat_title();
카테고리의 설명이 있는 경우 설명을 불러옴
echo category_description();
카테고리의 설명이 있는 경우 설명을 불러옴
워드프레스 댓글정보 관련
comment_author();
댓글 작성자 이름표시
comment_author_email();
댓글 작성자 이메일표시
comment_author_IP();
댓글 작성자 IP주소 표시
comment_author_url();
댓글 작성자 URL 표시
comment_class();
댓글에 클래스 선택자 추가
(ex) comment_class(‘best’); 댓글에 best클래스.
comment_date();
댓글 올린 날짜 표시
comment_excerpt();
댓글 요약(최대 20단어) 표시
comment_ID();
댓글의 숫자 아이디 표시
comment_reply_link( $args, $comment, $post );
댓글에 대한 댓글 링크 표시
comment_text( $comment_ID );
댓글 내용표시
comment_time();
댓글 올린 시간 표시
(ex) comment_time(‘H:i:s’);
comments_link();
댓글 창으로 가는 링크표시
comments_number( $zero, $one, $more );
댓글 수 표시하는 방법
(ex) comments_number(‘코멘트가 없습니다.’, ‘댓글이 1개 있습니다.’, ‘댓글 %개’);
$zero는 코멘트가 없을 때 표시되는 것.
$one는 댓글이 1개일 때
$more는 복수의 댓글을 표시할 때 %는 댓글 수를 표시합니다.
comments_popup_link();
댓글 입력창으로 가는 링크표시
워드프레스 기타 함수태그
the_permalink();
반복문에서 글 고유 주소의 URL을 표시
echo get_permalink( $id );
고유 URL주소 표시
(ex) echo get_permalink( 268 );
268번 글의 고유주소
edit_comment_link( $link );
반복문에서 댓글편집 링크 표시
(ex) edit_comment_link( ‘댓글 편집’ );
‘댓글 편집’ 링크 생성
edit_post_link( $link );
반복문에서 글 편집 링크 표시
(ex) edit_post_link( ‘편집’ );
‘편집’ 링크 생성
body_class( $class );
클래스 선택자를 만듬
(ex) <body body_class($class); >
$class명을 가진 클래스 선택자를 만듬
post_class();
글의 클래스 선택자를 만듬
(ex) <div id=”post-the_ID();” post_class();>
single_post_title();
단일 글에서 제목 표시
the_category();
글의 카테고리 링크 표시
the_content();
글의 내용 표시
the_excerpt();
반복문에서 말 줄임표(…)를 포함한 요약 글 표시
the_ID();
반복문에서 현재 글의 아이디 숫자 표시
the_tags( $before, $sep, $after );
반복문에서 글 태그 표시
(ex) the_tags( ‘TAG’, ‘, ‘, ‘<br/>’ );
$before는 태그가 출력되는 앞에 표시될 이름
$sep은 태그별 구분자
$after는 태그가 완료된 후 표시
the_title( $before, $after, $echo );
반복문에서 현재 글의 제목 표시
(ex) the_title( ‘<h3>‘, ’</h3>’ );
the_date( $format, $before, $after, $echo );
반복문에서 현재 글의 제목 표시
(ex) the_date( ‘Y-m-d‘, ’<h2>’, ‘</h2>’ );
2013년 3월 1일 로 출력
the_time( $d );
반복문에서 현재 글의 작성시간 표시
(ex) the_time( ‘g:i a‘ );
[출처] 워드프레스 템플릿 함수태그|작성자 dealex
728x90