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 私のデジタルライフフォーラム .です。



13 Responses to “Retrieve and Get WordPress Post ID Outside the Loop as PHP Variable” 13レスポンスを"郵便番号取得し、取得WordPressのPHP変数として外部のループ"

  1. Joel Pジョエルp
    December 1st, 2006 06:06 2006年12月1日06:06
    1

    This is really good thing to know… I think i’ll try to use this with my blog and limited php knowledge.これは本当にいいことを知って…と思うとやってみますこのブログを使用すると限られたPHPの知識です。

  2. Mattマット
    May 3rd, 2007 05:10 2007年5月3日05:10
    2

    Just what I was looking for, thanks!私は何を探して、ありがとう!

  3. Christopheクリストフ
    May 16th, 2007 14:15 2007年5月16日14:15
    3 4

    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

  4. k
    June 28th, 2007 11:55 2007年6月28日11:55
    4

    Great info.大きなに関する情報です。 Needed this a few days ago.必要に応じて、この数日前にします。 Will update my code with this direct approach.私は、更新プログラムのコードをこの直接的なアプローチです。 Thanks.ありがとう。

  5. Ericエリック
    September 21st, 2007 07:51 2007年9月21日07:51
    5

    Thanks, using ‘global $id;’ in a filter for my plugin got me the post id I needed.ありがとう、を使用して'グローバル$番号; 'をするフィルタの私の差込式は私を必要に応じて、郵便番号私です。

  6. Osordvibil osordvibil
    October 6th, 2007 00:09 2007年10月6日00:09
    6

    comment_fashion

  7. 让WP不同页面使用不同设计 | 收拾起大地山河一担装让WPの不同页面使用不同设计|收拾起大地山河一担装
    October 10th, 2007 21:05 2007年10月10日21:05
    7

    [...] 使用post ID变量可以做到。$post->ID可以返回文章的唯一编号。 [...]郵便番号变量可以做到[...]使用します。 $ポスト- >番号可以返回文章的唯一编号。 [...]

  8. Reviewsレビュー
    April 18th, 2008 18:11 2008年4月18日18:11
    8

    Thanks!ありがとう! That’s just what i am looking for.それはまさに私を探しています。 I want to get post id on the wordpress index (root) page.郵便番号を取得したいWordPressのインデックスを検索する(ルート)ページをご覧ください。

  9. Shopsショップ
    May 6th, 2008 20:02 2008年5月6日20:02
    9

    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のです。

  10. Johannesヨハネス
    June 16th, 2008 03:27 2008年6月16日03:27
    10

    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?このようは何か可能ですか?

  11. Johannesヨハネス
    June 16th, 2008 03:27 2008年6月16日03:27
    11 11日

    Forgot Notification of followups. followupsの通知を忘れてしまった。 Thanks.ありがとう。

  12. PieterC pieterc
    June 17th, 2008 14:02 2008年6月17日14:02
    12

    Thank you.ありがとうございました。 It works like a charm!それ作品のように魅力的!

  13. Danielダニエル
    June 18th, 2008 09:34 2008年6月18日09:34
    13 13日

    Thanks for this - this did absolutely what I needed to do.ありがとう、この-これは確実に私が必要に応じてこれを行うにします。 : )

Leave a Reply残して返信

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> これらのタグを使用することができます: <aのhref=のtitle= <abbrのtitle= <blockquote cite=""> <cite> <acronymのtitle= <b>ダウンロードの<code> <デル日時= " " >の<em> <i>て<strike> <strong> <q cite="">

Subscribe without commenting登録なしのコメント


Custom Search

New Articles新しい記事

Incoming Search Terms for the Article検索用語を受信するには

wordpress post id WordPressの郵便番号 - - wordpress get post id WordPressの取得郵便番号 - - wordpress get page id WordPressの入手ページ番号 - - post id wordpress 郵便番号のWordPress - - wordpress page id WordPressのページ番号 - - get post ID Wordpress 郵便番号WordPressの取得 - - $post->ID $ポスト- >番号 - - wordpress $post->id WordPressの$ポスト- >番号 - - wordpress the_ID WordPressのthe_id - - wordpress get current page id WordPressの入手現在のページ番号 - - wordpress post object WordPressのポストオブジェクト - - wordpress get id WordPressの取得番号 - - wordpress get current page 現在のページWordPressの取得 - - wordpress current page id WordPressの現在のページ番号 - - page ID wordpress ページ番号のWordPress - - wordpress get category id WordPressの入手カテゴリID - - wordpress get post by id WordPressの取得投稿者番号 - - wordpress if post id WordPressの場合に郵便番号 - - wordpress post_id WordPressのpost_id - - $post->ID wordpress $ポスト- >番号のWordPress - - wordpress get post WordPressの入手ポスト - - wordpress post variable WordPressのポスト変数 - - wordpress current post id WordPressの現在の郵便番号 - - wordpress $post object WordPressの$ postオブジェクト - - wordpress post->ID WordPressのポスト- >番号 - - wordpress postid WordPressのpostid - - wordpress $post WordPressの$ポスト - - get post id 郵便番号取得 - - get id wordpress 取得番号のWordPress - - wordpress post variables WordPressのPOST変数 - - wordpress get current post WordPressの現在のポスト - - get post id in wordpress WordPressの郵便番号を取得 - - post id 郵便番号 - - wordpress pageid WordPressのページID - - wordpress $post variable WordPressの変数$ポスト - - wordpress get current category id 現在のカテゴリIDのWordPress - - wordpress get current post id WordPressの現在の郵便番号 - - wordpress get post category id WordPressの取得作成カテゴリID - - post->id ポスト- >番号 - - wordpress $post_id WordPressの$ post_id - - get wordpress post id 取得WordPressの郵便番号 - - get page ID wordpress 取得ページ番号のWordPress - - wordpress the_id() WordPressのthe_id ( ) - - wordpress get id of current page WordPressの現在のページのIDを取得 - - wordpress get page by id WordPressのページを取得番号 - - wordpress id post WordPressの番号の投稿 - - wordpress change post id WordPressの郵便番号の変更 - - wordpress get posts WordPressの記事を取得 - - the_ID wordpress WordPressのthe_id - - wordpress outside the loop WordPressの外部のループ - -