Retrieve and Get WordPress Post ID Outside the Loop as PHP Variable郵便番号取得し、取得WordPressのPHP変数として外部のループ
In WordPress, each post has unique anchor identifier in the form of numeric post ID. WordPressのは、それぞれの投稿には固有の識別子の形でアンカーの数値郵便番号です。 When inside the Loop, where WordPress processes and displays each of the posts to be displayed on the current page and formats them according to how they match specified criteria within The Loop tags, template tag the_ID can be used to easily display the post’s ID inside the post.ループ内のときに、ここで表示されます。 WordPressのプロセスとそれぞれの記事を、現在のページに表示されるとフォーマットをして試合によると、指定した条件にどのようにループタグは、テンプレートタグを使用して簡単にthe_idの投稿の番号を表示する内部のポストを作成。 Alternatively, inside the the_content filter, declare $id global and use $id to retrieve the post ID.また、内部のthe_contentフィルタは、全世界を対象と使用する番号を宣言$ $番号を取得するに郵便番号です。
the_ID template tag can be used in the following format: the_idテンプレートタグに使用されることは、次の形式:
<?php the_ID(); ?> <ですか? PHPのthe_id ( ) ;ですか? >
Outside the Loop or out of the context of the post, such as in header of footer and even sidebar area in the templates of WordPress’s blog, the_ID() cannot be used as a function.外部のループか、除外するには、投稿のコンテキストでは、ヘッダーフッターのように、さらにはWordPressのサイドバーに表示されているテンプレートのブログ、 the_id ( )関数として使用されることはできません。 Instead, $post->ID will be used to return the post ID (the syntax can also be used inside the Loop of the post by declaring $post as global).その代わりに、 $ポスト- >番号を返すために使用される郵便番号(の構文に使われることもできます。内側のループを宣言するには、投稿$ポストとしてグローバル)です。 $post is a global object that holds various information about the posts displayed on the page. $ポストは、グローバルオブジェクトを保持する様々な情報については、記事のページに表示されています。 So $post->ID will return the post ID of the post.これ$ポスト- >番号は郵便番号を返しますするには、投稿します。 It the $post is used inside a function, the $post has to be declared as a global variable. $ポストが使用されて、関数の中では、 $郵政公社がされるグローバル変数として宣言されています。 For example:例えば:
// Works inside of the Loop / /動作の内側に、ループ
function function_name() { 関数function_name ( ) (
global $post; グローバル$ポスト;
$thePostID = $post->ID; $ thepostid = $ポスト- >番号;
} )
or:または:
// Works in single post outside of the Loop / /作品を1つのポストの外側のループ
function function_name() { 関数function_name ( ) (
global $wp_query; グローバル$ wp_query ;
$thePostID = $wp_query->post->ID; $ thepostid = $ wp_query - >投稿- >番号;
} )
$post->ID can be called directly outside of the Loop too in a single post template, such as <?php echo $post->ID ?> will print display the post’s ID number. $ポスト- >番号を呼び出すことができますあまりにも直接のループ外のテンプレートを1つの投稿など、 <ですか? phpのエコー$ポスト- >番号ですか? >は、投稿のID番号を表示するに印刷します。
In the multiple posts view page such as index page or archive page, it’s possible to retrieve the get the latest or earliest post ID of all the posts displayed on the page by using an ORDER BY clause to order the posts by date, and then set the number of record to LIMIT 1.の記事を対象に、複数のページをインデックスページやアーカイブページなど、取得することが可能に取得して、最新の郵便番号または最古のすべての記事を使用してページに表示されてorder by句を注文するに投稿した日付、およびレコードの数を入力し、設定を制限する1 。
Just for example, and there are various way to use the query:わずかたとえば、とには様々な方法を使用してクエリ:
//Get the latest post ID number / / ID番号を入手して最新の投稿
$post->ID ORDER BY post_date ASC LIMIT 1 $ポスト- >番号順post_date昇順限界1
//Get the earliest post ID number / /ポストID番号を入手して最古
$post->ID ORDER BY post_date DESC LIMIT 1 $ポスト- >番号順post_date降順限界1
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要 :これは、機械翻訳ページで提供"現状有姿"を保証します。 Machine translation may be difficult to understand.機械翻訳を理解するのは難しいかもしれません。 Please refer toを参照してください original English articleオリジナルの英語記事索引 whenever possible.いつ可能です。
Share and contribute or get technical support and help atを共有して貢献や技術サポートとヘルプを得る My Digital Life Forums 私のデジタルライフフォーラム .です。
Related Articles関連記事
- Paginating or Split WordPress Post or Page with NextPage in WordPress Not Working paginatingまたは分割WordPressのページに投稿したりnextpageにWordPressが機能しない
- Disable and Turn Off Post Revisions Tracking in WordPress 2.6 or Above無効にしたり、改正後のトラッキングを無効にするにWordPress 2.6以降で動作
- How to Change the Frequency or Interval WordPress Auto Saves An Editing Post or Page周波数または間隔を変更する方法についてのWordPressの自動作成やページの編集を保存する
- WordPress MySQL SQL Query Error in WPDB Class WordPressのMySQLのSQLクエリにエラーが発生wpdbクラス
- Adding Extra More Fields to WordPress Write/Edit Post/Page Right Column余分な他のフィールドを追加するWordPressの書き込み/編集ポスト/ページの右側の列
- Disable Auto Go To (Jump) To Read More Tag無効にオートに行く(ジャンプ)をタグの続きを読む
- How To Store Every Post Revisions on Each Auto-Save in WordPress with Limit on Versions Countすべての投稿の改訂を格納する方法について、各自動保存さWordPressの数を制限しているバージョン
- 3 Column Relaxation WordPress Theme comments-paged.php for Paged-Comments WordPress Plugin 3つのコラムのテーマのコメント- paged.phpを緩和WordPressのページ-コメントWordPressの差込式
- How to Delete Existing WordPress Post Revisions Stored/Saved既存のWordPressの投稿を削除する方法の改訂に格納/保存
- Integrate WordPress including Comments with bbPress Forum using bbSync bbpress WordPressのフォーラムを含む統合を使用してコメントをbbsync



















December 1st, 2006 06:06 2006年12月1日06:06
This is really good thing to know… I think i’ll try to use this with my blog and limited php knowledge.これは本当にいいことを知って…と思うとやってみますこのブログを使用すると限られたPHPの知識です。
May 3rd, 2007 05:10 2007年5月3日05:10
Just what I was looking for, thanks!私は何を探して、ありがとう!
May 16th, 2007 14:15 2007年5月16日14:15
Found this through Google.これをGoogleが見つかりました。 Thanks!ありがとう! You should also enter this into the official WP documentation wiki:これを入力する必要も、公式のWPドキュメンテーションwiki : http://codex.wordpress.org/Main_Page http://codex.wordpress.org/main_page
June 28th, 2007 11:55 2007年6月28日11:55
Great info.大きなに関する情報です。 Needed this a few days ago.必要に応じて、この数日前にします。 Will update my code with this direct approach.私は、更新プログラムのコードをこの直接的なアプローチです。 Thanks.ありがとう。
September 21st, 2007 07:51 2007年9月21日07:51
Thanks, using ‘global $id;’ in a filter for my plugin got me the post id I needed.ありがとう、を使用して'グローバル$番号; 'をするフィルタの私の差込式は私を必要に応じて、郵便番号私です。
October 6th, 2007 00:09 2007年10月6日00:09
comment_fashion
October 10th, 2007 21:05 2007年10月10日21:05
[...] 使用post ID变量可以做到。$post->ID可以返回文章的唯一编号。 [...]郵便番号变量可以做到[...]使用します。 $ポスト- >番号可以返回文章的唯一编号。 [...]
April 18th, 2008 18:11 2008年4月18日18:11
Thanks!ありがとう! That’s just what i am looking for.それはまさに私を探しています。 I want to get post id on the wordpress index (root) page.郵便番号を取得したいWordPressのインデックスを検索する(ルート)ページをご覧ください。
May 6th, 2008 20:02 2008年5月6日20:02
Thanks for this.のおかげです。 You cant believe how long it took me to search for this simple answer!どれくらい時間がかかったができないと考え、この単純明快な答えを検索する私! I dont know why you cant find it on wordpress.私dontできない理由を見つけることを知ってWordPressのです。
June 16th, 2008 03:27 2008年6月16日03:27
Hi,やあ、
thanks for these informations.これらの情報をいただきありがとうございます。
I tried to configure something without any luck and hope you can help me.何かを構成することなくてみました幸運と希望することができます。手伝っています。
I’m using wordpress as a blog and do have a few pictures in every blog.私は使用してのWordPressとしてのブログにしては、いくつかの画像をすべてのブログです。
Now I want to implement a feature like shadowbox to popup the images.今すぐ欲しい機能を実装するのポップアップの画像のようなボクシングのまねをしています。 To do this automatically, I put a rel=”shadowbox[imageset]” in the anchors of the images.これを行うには自動的に、私にrel =の"シャドーボクシング[ imageset ] "は、アンカーの画像です。
What do I have to do to put the post-title or ID instead of imageset.これを行うにはどうしたらよいポストに配置するタイトルや番号の代わりにimagesetです。
Is something like this possible?このようは何か可能ですか?
June 16th, 2008 03:27 2008年6月16日03:27
Forgot Notification of followups. followupsの通知を忘れてしまった。 Thanks.ありがとう。
June 17th, 2008 14:02 2008年6月17日14:02
Thank you.ありがとうございました。 It works like a charm!それ作品のように魅力的!
June 18th, 2008 09:34 2008年6月18日09:34
Thanks for this - this did absolutely what I needed to do.ありがとう、この-これは確実に私が必要に応じてこれを行うにします。