- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「テンプレートタグ/get bookmarks」の版間の差分
提供: WordPress Codex 日本語版
< テンプレートタグ
(関数リファレンス/get bookmarksへのリダイレクト) |
(00:21, June 28, 2013 Obenland 版の英語版を全体にコピペ。) |
||
1行目: | 1行目: | ||
− | # | + | <div id="Description"> |
+ | == 説明 == | ||
+ | </div> | ||
+ | この関数は[[管理画面]] > [[管理パネル/リンク|リンク]] > [[Links_Edit_SubPanel#.E3.83.AA.E3.83.B3.E3.82.AF_.E2.86.92_.E7.B7.A8.E9.9B.86|編集]]画面にあるブックマークの配列を返すものです。この[[Template Tags|テンプレートタグ]]はブックマークの情報を直に取得するものです。 | ||
+ | |||
+ | <div id="Usage"> | ||
+ | == 使い方 == | ||
+ | </div> | ||
+ | <?php get_bookmarks( $args ); ?> | ||
+ | |||
+ | <div id="Default_Usage"> | ||
+ | === 初期設定での使用 === | ||
+ | </div> | ||
+ | <pre><?php $args = array( | ||
+ | 'orderby' => 'name', | ||
+ | 'order' => 'ASC', | ||
+ | 'limit' => -1, | ||
+ | 'category' => '', | ||
+ | 'category_name' => '', | ||
+ | 'hide_invisible' => 1, | ||
+ | 'show_updated' => 0, | ||
+ | 'include' => '', | ||
+ | 'exclude' => '', | ||
+ | 'search' => '' ); ?></pre> | ||
+ | |||
+ | By default, the usage gets: | ||
+ | * All bookmarks ordered by name, ascending | ||
+ | * Bookmarks marked as hidden are not returned. | ||
+ | * The link_updated_f field (the update time in the form of a timestamp) is not returned. | ||
+ | |||
+ | <div id="Parameters"> | ||
+ | == パラメータ == | ||
+ | </div> | ||
+ | ; orderby : (''string'') Value to sort bookmarks on. Defaults to <tt>'name'</tt>. Valid options: | ||
+ | :* <tt>'link_id'</tt> - Before WordPress 3.2: <tt>'id'</tt> | ||
+ | :* <tt>'url'</tt> | ||
+ | :* <tt>'name'</tt> - Default | ||
+ | :* <tt>'owner'</tt> - User who added bookmark through bookmarks Manager. | ||
+ | :* <tt>'rating'</tt> | ||
+ | :* <tt>'visible'</tt> | ||
+ | :* <tt>'length'</tt> - The length of the bookmark name, shortest to longest. | ||
+ | :* <tt>'rand'</tt> - Display bookmarks in random order. | ||
+ | |||
+ | ; order : (''string'') Sort order, ascending or descending for the orderby parameter. Valid values: | ||
+ | :* <tt>ASC</tt> - Default | ||
+ | :* <tt>DESC</tt> | ||
+ | |||
+ | ; limit : (''integer'') Maximum number of bookmarks to display. Defaults to <tt>-1</tt> (all bookmarks). | ||
+ | |||
+ | ; category : (''string'') Comma separated list of bookmark category ID's. | ||
+ | |||
+ | ; category_name : (''string'') Category name of a category of bookmarks to retrieve. Overrides category parameter. | ||
+ | |||
+ | ; hide_invisible : (''boolean'') TRUE causes only bookmarks with link_visible set to 'Y' to be retrieved. | ||
+ | :* <tt>1</tt> (True) - Default | ||
+ | :* <tt>0</tt> (False) | ||
+ | |||
+ | ; show_updated : (''boolean'') TRUE causes an extra column called "link_category_f" to be inserted into the results, which contains the same value as "link_updated", but in a unix timestamp format. Handy for using PHP date functions on this data. | ||
+ | :* <tt>1</tt> (True) | ||
+ | :* <tt>0</tt> (False) - Default | ||
+ | |||
+ | ; include : (''string'') Comma separated list of numeric bookmark IDs to include in the output. For example, 'include=1,3,6' means to return or echo bookmark IDs 1, 3, and 6. If the include string is used, the ''category'', ''category_name'', and ''exclude'' parameters are ignored. Defaults to <tt>''</tt> (all Bookmarks). | ||
+ | |||
+ | ; exclude : (''string'') Comma separated list of numeric bookmark IDs to exclude. For example, 'exclude=4,12' means that bookmark IDs 4 and 12 will NOT be returned or echoed. Defaults to <tt>''</tt> (exclude nothing). | ||
+ | |||
+ | ; search : (''string'') Searches <tt>link_url</tt>, <tt>link_name</tt> or <tt>link_description</tt> like the <tt>search</tt> string. Defaults to <tt>''</tt>. | ||
+ | |||
+ | == Return Values == | ||
+ | ; (array) : List of bookmark row objects. Each bookmark object may contain the following: 'link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated', 'link_rel', 'link_notes', 'link_rss' | ||
+ | |||
+ | <div id="Examples"> | ||
+ | == 使用例 == | ||
+ | </div> | ||
+ | - Create a link category named "Related Sites"<br /> | ||
+ | - Create a few links, adding them to the "Related Sites" category | ||
+ | |||
+ | You may use the following code in your templates to retrieve the links: | ||
+ | <pre> | ||
+ | <?php | ||
+ | $bookmarks = get_bookmarks( array( | ||
+ | 'orderby' => 'name', | ||
+ | 'order' => 'ASC', | ||
+ | 'category_name' => 'Related Sites' | ||
+ | )); | ||
+ | |||
+ | // Loop through each bookmark and print formatted output | ||
+ | foreach ( $bookmarks as $bookmark ) { | ||
+ | printf( '<a class="relatedlink" href="%s">%s</a><br />', $bookmark->link_url, $bookmark->link_name ); | ||
+ | } | ||
+ | ?> | ||
+ | </pre> | ||
+ | |||
+ | <div id="Change Log"> | ||
+ | == 改訂履歴 == | ||
+ | </div> | ||
+ | [[Version 2.1]] にて導入されました。 | ||
+ | |||
+ | <div id="Source File"> | ||
+ | == ソースファイル == | ||
+ | </div> | ||
+ | <tt>get_bookmarks()</tt> は {{Trac|wp-includes/bookmark.php}} にあります。 | ||
+ | |||
+ | <div id="Related"> | ||
+ | == 関連項目 == | ||
+ | </div> | ||
+ | |||
+ | {{原文|Template Tags/get_bookmarks|132614}}<!-- 00:21, June 28, 2013 Obenland 版 --> | ||
+ | |||
+ | |||
+ | {{Bookmark Tags}} | ||
+ | |||
+ | {{Tag Footer}} | ||
+ | |||
+ | [[Category:Functions]] |
2014年2月8日 (土) 20:52時点における版
この関数は管理画面 > リンク > 編集画面にあるブックマークの配列を返すものです。このテンプレートタグはブックマークの情報を直に取得するものです。
使い方
<?php get_bookmarks( $args ); ?>
初期設定での使用
<?php $args = array( 'orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '', 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '', 'search' => '' ); ?>
By default, the usage gets:
- All bookmarks ordered by name, ascending
- Bookmarks marked as hidden are not returned.
- The link_updated_f field (the update time in the form of a timestamp) is not returned.
パラメータ
- orderby
- (string) Value to sort bookmarks on. Defaults to 'name'. Valid options:
- 'link_id' - Before WordPress 3.2: 'id'
- 'url'
- 'name' - Default
- 'owner' - User who added bookmark through bookmarks Manager.
- 'rating'
- 'visible'
- 'length' - The length of the bookmark name, shortest to longest.
- 'rand' - Display bookmarks in random order.
- order
- (string) Sort order, ascending or descending for the orderby parameter. Valid values:
- ASC - Default
- DESC
- limit
- (integer) Maximum number of bookmarks to display. Defaults to -1 (all bookmarks).
- category
- (string) Comma separated list of bookmark category ID's.
- category_name
- (string) Category name of a category of bookmarks to retrieve. Overrides category parameter.
- hide_invisible
- (boolean) TRUE causes only bookmarks with link_visible set to 'Y' to be retrieved.
- 1 (True) - Default
- 0 (False)
- show_updated
- (boolean) TRUE causes an extra column called "link_category_f" to be inserted into the results, which contains the same value as "link_updated", but in a unix timestamp format. Handy for using PHP date functions on this data.
- 1 (True)
- 0 (False) - Default
- include
- (string) Comma separated list of numeric bookmark IDs to include in the output. For example, 'include=1,3,6' means to return or echo bookmark IDs 1, 3, and 6. If the include string is used, the category, category_name, and exclude parameters are ignored. Defaults to (all Bookmarks).
- exclude
- (string) Comma separated list of numeric bookmark IDs to exclude. For example, 'exclude=4,12' means that bookmark IDs 4 and 12 will NOT be returned or echoed. Defaults to (exclude nothing).
- search
- (string) Searches link_url, link_name or link_description like the search string. Defaults to .
Return Values
- (array)
- List of bookmark row objects. Each bookmark object may contain the following: 'link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated', 'link_rel', 'link_notes', 'link_rss'
使用例
- Create a link category named "Related Sites"
- Create a few links, adding them to the "Related Sites" category
You may use the following code in your templates to retrieve the links:
<?php $bookmarks = get_bookmarks( array( 'orderby' => 'name', 'order' => 'ASC', 'category_name' => 'Related Sites' )); // Loop through each bookmark and print formatted output foreach ( $bookmarks as $bookmark ) { printf( '<a class="relatedlink" href="%s">%s</a><br />', $bookmark->link_url, $bookmark->link_name ); } ?>
改訂履歴
Version 2.1 にて導入されました。
ソースファイル
get_bookmarks() は wp-includes/bookmark.php
にあります。
関連項目
最新英語版: WordPress Codex » Template Tags/get_bookmarks (最新版との差分)
ブックマークタグ: wp_list_bookmarks, get_bookmarks, get_bookmark get_bookmark_field
関数リファレンス、テンプレートタグ目次もご覧ください。