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. في الكلمات لكل وظيفة فريدة معرف في ارساء شكل من اشكال ما بعد الهوية الرقميه. 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() { وظيفة function_name () (
global $post; دولار العالمية بعد ؛
$thePostID = $post->ID; thepostid دولار = دولار بعد انتهاء> الهوية ؛
} )
or: أو :
// Works in single post outside of the Loop / / وتعمل في وظيفة واحدة من خارج الحلقه
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. دولار بعد انتهاء> الهوية يمكن ان تسمي مباشرة من خارج الحلقه ايضا في قالب واحد بعد ، مثل <؟ بي. اتش. بي أردد دولار بعد انتهاء> الهوية؟> طباعة سوف تظهر بعد للرقم بطاقه الهوية.
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. في صفحة الرأي وظائف متعددة مثل صفحة فهرس او ارشيف الصفحه ، فمن الممكن لاستعادة أحصل على آخر او اقرب ما بعد من هوية جميع الوظائف المعروضة على الصفحه باستخدام امر صادر عن الحكم لأجل الوظائف حسب التاريخ ، و بعد ذلك حدد عدد من سجل للحد من 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 ASC من اجل الحد من 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 المادة الاصليه English 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 ترقيم صفحات 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 الخلية لغة الاستعلامات البنيويه استفسار خطأ في الدرجة 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 العمود الاسترخاء WordPress موضوع تعليقات للصفحات paged.php - - التعليقات وردبريس البرنامج المساعد
- How to Delete Existing WordPress Post Revisions Stored/Saved لحذف القائمة WordPress ما بعد التنقيحات المخزنه / انقاذ
- Integrate WordPress including Comments with bbPress Forum using bbSync WordPress دمج بما في ذلك التعليقات مع bbpress المنتدى باستخدام bbsync

































December 1st, 2006 06:06 كانون الاول / ديسمبر 1st ، 2006 06:06
This is really good thing to know… I think i’ll try to use this with my blog and limited php knowledge. وهذا هو حقا شيء جيد ان يعرف… واعتقد انني سوف تحاول استخدام هذا مع بلادي بي. اتش. بى بلوق ومحدوديه المعرفه.
May 3rd, 2007 05:10 ايار / مايو 3rd ، 2007 05:10
Just what I was looking for, thanks! فقط ما كنت تبحث عنه ، شكرا!
May 16th, 2007 14:15 ايار / مايو 16th ، 2007 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 يونيو 28th ، 2007 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 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 00:09
comment_fashion
October 10th, 2007 21:05 العاشر من تشرين الاول / اكتوبر ، 2007 21:05
[...] 使用post ID变量可以做到。$post->ID可以返回文章的唯一编号。 [...] [...]使用بعد معرف变量可以做到. دولار بعد انتهاء> معرف可以返回文章的唯一编号. [...]
April 18th, 2008 18:11 نيسان / ابريل 18th ، 2008 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 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 يونيو 16th ، 2008 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. للقيام بذلك تلقائيا ، الاول وضع rel = "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 يونيو 16th ، 2008 03:27
Forgot Notification of followups. نسيت اخطار من المتابعات. Thanks. شكرا.
June 17th, 2008 14:02 يونيو 17th ، 2008 14:02
Thank you. شكرا لك. It works like a charm! وهي تعمل مثل السحر!
June 18th, 2008 09:34 يونيو 18th ، 2008 09:34
Thanks for this - this did absolutely what I needed to do. شكرا لهذا -- هذا على الاطلاق ما لم يلزم القيام به.