Template Tags/get archives

From 워드프레스(WORDPRESS) 한국어 위키

Jump to: navigation, search

Contents

Description

이 함수를 이용해 날짜별 글 목록을 출력 할 수 있으며 방식은 wp_get_archives() 와 동일하다. 두 함수의 차이점은 함수 설정값 입력 방식에 있다. 이 함수는 템플릿 파일의 어느 곳에서도 사용 될 수 있다.

Usage

<?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?>

Examples

Default Usage

워드프레스 기본값을 사용해 글 목록을 출력

<?php get_archives(); ?>

By Month with Post Count

월별 글 목록을 갯수에 제한 없이 해당 글의 갯수와 함께 리스트 태그(<li>)를 사용해 출력

<ul>
<?php get_archives('monthly', '', 'html', '', '', TRUE); ?>
</ul>

Displays Last 10 Posts In A List

최근 10개의 글 목록을 리스트 태그를 사용하지 않고 줄 건너띄기(<br />)를 사용해 출력

<?php get_archives('postbypost', '10', 'custom', '', '<br />'); ?>

Using Dropdown List

펼침(drop-down)목록을 사용해 월별 목록을 출력. 선택된 페이지로 이동하기 위해 자바스크립트 의 사용이 필요하다.

<form id="archiveform" action="">
<select name="archive_chrono" onchange="window.location =
(document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">
<option value=''>Select Month</option>
<?php get_archives('monthly','','option'); ?>
</select>
</form>

위의 것보다 조금 더 간단하게 아래의 코드(태그)를 사용하는 방법도 있다. 마찬가지로 월별 목록을 출력해 주며 해당 글의 갯수도 출력해 준다.

<form id="archiveform" action="">
 <select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
 <option value="">Select month</option>
 <?php get_archives('monthly',,'option',,,'TRUE'); ?>
 </select>
</form>

List of Limited Number of Recent Posts

사용자가 지정한 갯수 만큼의 최근 글 목록을 출력한다.(10개) 기본값인 리스트 태그(<li>) 사용.

 <ul><?php get_archives('postbypost','10'); ?></ul>

Parameters

type 
(문자) 출력할 목록의 타입을 결정. 올바른 입력값:
  • monthly - 월별(기본값)
  • daily - 일별
  • weekly - 주별
  • postbypost - 글별
limit 
(숫자) 가져올 목록의 갯수. 기본값 : 전체.
format 
(문자) 글 목록을 출력 할 포멧. 올바른 입력값:
  • html - HTML 리스트 태그(<li>) 사용. (기본값)
  • option - 선택상자(select 태그) 사용(<option>).
  • link - 일반적인 링크 태그(<link>) 사용.
  • custom - 사용자 지정.
before 
(문자) format 값에 custom 또는 html을 사용했을 경우 링크 앞에 표시될 문구(혹은 태그) 지정. 기본값 없슴.
after 
(문자) format 값에 custom 또는 html을 사용했을 경우 링크 뒤에 표시될 문구(혹은 태그) 지정. 기본값 없슴.
show_post_count 
(TRUE 또는 FALSE) 해당 글의 갯수 표시 여부 결정. (TRUE - 표시), (FALSE - 표시안함). type 설정값이 'monthly' 일때 사용. 기본값은 FALSE.

Related

To use the query string to pass parameters to generate an archive list, see wp_get_archives()

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, get_archives, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_loginout, wp_register, query_posts, rss_enclosure

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Personal tools