Retrieve and Get WordPress Post ID Outside the Loop as PHP Variable 밖으로 가서 루프 wordpress 게시물 번호를 검색 환경 변수 변수

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(); ?> <함수 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() { 기능을 함수 () (
global $post; 글로벌 $ 포스트;
$thePostID = $post->ID; $ thepostid = $ 포스트 -> 번호;
} )

or: 또는 :


// Works in single post outside of the Loop / / 작동합니다 이외의 루프를 단일 게시물
function 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. $ 포스트 -> 번호를 직접라고 불릴 수있습니다 루프 너무을 단일 게시물 이외의 서식 파일과 같은 <함수 에코 $ 포스트 ->셨습니까?>를 인쇄 게시물의 번호를 표시합니다.

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. 여러 개의 게시물보기 페이지에서와 같은 인덱스 페이지 또는 아카이브 페이지를 검색하는 들여볼 수있게되었습니다 또는 최초 게시물 번호를 최신의 모든 명령을 사용하여이 페이지에 표시되는 게시물에 어구를 주문하는 게시물을 날짜 및 하나의 개수를 제한하는 레코드를 설정합니다.

Just for example, and there are various way to use the query: 단지 예를 들면, 그리고 이미 다양한 방법을 사용하는 검색어 :

//Get the latest post ID number / / 최신 게시물 번호
$post->ID ORDER BY post_date ASC LIMIT 1 $ 포스트 -> 번호 순서 post_date 오름차순 한도 1

//Get the earliest post ID number / / 최초의 게시물 번호
$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 게시물 번호를 검색 이외의 루프 환경 변수 변수"

  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

    Found this through Google. 이것을 통해 발견 구글합니다. Thanks! 감사합니다! You should also enter this into the official WP documentation 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. 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不同页面使用不同设计 | 收拾起大地山河一担装让백린不同页面使用不同设计|收拾起大地山河一担装
    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. 잘 모르겠습니다 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. 지금처럼 원하는 기능을 구현하는 팝업의 이미지를 shadowbox합니다. To do this automatically, I put a rel=”shadowbox[imageset]” in the anchors of the images. 이렇게 자동으로, 나를 설치해 버전 = "shadowbox [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

    Forgot Notification of followups. followups를 잊으의 통지합니다. Thanks. thanks.

  12. PieterC pieterc
    June 17th, 2008 14:02 2008년 6월 17일 14:02
    12

    Thank you. thank you. It works like a charm! 이 작품의 매력처럼!

  13. Daniel 다니엘
    June 18th, 2008 09:34 2008년 6월 18일 09:34
    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=""> <acronym title=""> <abbr title=""> <blockquote cite=""> <b> <cite> <code> <델 날짜 = ""> <em> <i> <strike> '<q cite="">

Subscribe without commenting 논평없이 구독 신청
이메일


Custom Search

New Articles 새로운 기사

Incoming Search Terms for the Article 이 문서에 대한 검색어를 수신

wordpress post id wordpress 게시물 번호 - - wordpress get post id wordpress get 게시물 번호 - - wordpress get page id wordpress get 페이지 번호 - - post id wordpress 게시물 번호 wordpress - - get post ID Wordpress get 게시물 번호 wordpress - - wordpress page id wordpress 페이지 번호 - - $post->ID $ 포스트 -> 번호 - - wordpress $post->id wordpress $ 포스트 -> 번호 - - wordpress the_ID wordpress the_id - - wordpress get id wordpress get 번호 - - wordpress get current page id 현재 페이지 번호 wordpress - - wordpress current page id wordpress 현재 페이지 번호 - - wordpress post object 게시물 개체를 wordpress - - wordpress get current page 현재 페이지를 wordpress - - wordpress post_id wordpress post_id - - page ID wordpress 페이지 번호 wordpress - - wordpress current post id 현재 진행중인 게시 번호 wordpress - - $post->ID wordpress $ 포스트 -> 번호 wordpress - - wordpress post->ID wordpress 포스트 -> 번호 - - wordpress if post id 게시물 번호 wordpress 경우 - - wordpress get category id wordpress get 카테고리 - - wordpress get post by id wordpress get 게시물을 번호 - - wordpress get post wordpress get 게시물 - - wordpress post variable 포스트 변수를 wordpress - - wordpress get current post 현재 게시물 wordpress - - get post id get 게시물 번호 - - wordpress post variables 포스트 변수를 wordpress - - wordpress $post object wordpress $ 게시물 개체를 - - post id 게시물 번호 - - wordpress postid wordpress postid - - wordpress $post wordpress $ 게시물 - - wordpress get current category id 현재 카테고리 wordpress - - post->id 포스트 -> 번호 - - wordpress get current post id 현재 게시물 번호 wordpress - - get id wordpress get 번호 wordpress - - wordpress get post category id wordpress get 게시물 카테고리 - - wordpress $post variable wordpress $ 포스트 변수 - - get post id in wordpress get 게시물 신분증이 wordpress - - wordpress pageid wordpress pageid - - wordpress get post id outside of loop 루프 밖으로 wordpress get 게시물 번호 - - get page ID wordpress get 페이지 번호 wordpress - - wordpress the_id() wordpress the_id () - - wordpress get id of current page wordpress get 번호 현재의 페이지를 - - wordpress get page by id wordpress get 페이지의 번호 - - wordpress get latest post wordpress get 최신 게시물 - - wordpress $post_id wordpress $ post_id - - wordpress page id outside loop 외부 루프 wordpress 페이지 번호 - - get wordpress post id get wordpress 게시물 번호 - - wordpress id post wordpress 번호 게시물 - - postid wordpress postid wordpress - -