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 내 디지털 라이프 공개 토론 . 합니다.
Related Articles 관련 기사
- Paginating or Split WordPress Post or Page with NextPage in WordPress Not Working 페이지에 게시하거나 nextpage paginating 또는 분할 wordpress 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 wpdb 클래스에 오류가 mysql sql 쿼리를 wordpress
- 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 개의 란 wordpress 테마 코멘트 - paged.php을 이완을 호출 - 의견 플러그 접속식
- 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. 이것을 통해 발견 구글합니다. Thanks! 감사합니다! You should also enter this into the official WP documentation 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. 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. 잘 모르겠습니다 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. 지금처럼 원하는 기능을 구현하는 팝업의 이미지를 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? 이 적들역시 수 있나요?
June 16th, 2008 03:27 2008년 6월 16일 03:27
Forgot Notification of followups. followups를 잊으의 통지합니다. Thanks. thanks.
June 17th, 2008 14:02 2008년 6월 17일 14:02
Thank you. 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. 이것 주셔서 감사합니다 - 이것은 절대 해야할일을 했어요.