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 بلدي الرقميه الحياة المنتديات .



13 Responses to “Retrieve and Get WordPress Post ID Outside the Loop as PHP Variable” 13 ردود على "واسترجاعها والحصول على رقم تعريف WordPress ما بعد خارج الحلقه كما بي. اتش. بى متغير"

  1. Joel P ف جويل
    December 1st, 2006 06:06 كانون الاول / ديسمبر 1st ، 2006 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. وهذا هو حقا شيء جيد ان يعرف… واعتقد انني سوف تحاول استخدام هذا مع بلادي بي. اتش. بى بلوق ومحدوديه المعرفه.

  2. Matt مات
    May 3rd, 2007 05:10 ايار / مايو 3rd ، 2007 05:10
    2

    Just what I was looking for, thanks! فقط ما كنت تبحث عنه ، شكرا!

  3. Christophe كريستوف
    May 16th, 2007 14:15 ايار / مايو 16th ، 2007 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 يونيو 28th ، 2007 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 07:51
    5

    Thanks, using ‘global $id;’ in a filter for my plugin got me the post id I needed. شكرا ، باستخدام 'الهوية العالمية دولار ؛' فلتر في البرنامج المساعد لبلدي حصلت لي وظيفة احتاج الهوية.

  6. Osordvibil
    October 6th, 2007 00:09 السادس من تشرين الاول / اكتوبر ، 2007 00:09
    6

    comment_fashion

  7. 让WP不同页面使用不同设计 | 收拾起大地山河一担装让رزمه العمل不同页面使用不同设计|收拾起大地山河一担装
    October 10th, 2007 21:05 العاشر من تشرين الاول / اكتوبر ، 2007 21:05
    7

    [...] 使用post ID变量可以做到。$post->ID可以返回文章的唯一编号。 [...] [...]使用بعد معرف变量可以做到. دولار بعد انتهاء> معرف可以返回文章的唯一编号. [...]

  8. Reviews الاستعراضات
    April 18th, 2008 18:11 نيسان / ابريل 18th ، 2008 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 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 يونيو 16th ، 2008 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. للقيام بذلك تلقائيا ، الاول وضع 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? شيء مثل هذا ممكن؟

  11. Johannes يوهانز
    June 16th, 2008 03:27 يونيو 16th ، 2008 03:27
    11

    Forgot Notification of followups. نسيت اخطار من المتابعات. Thanks. شكرا.

  12. PieterC Pieterc
    June 17th, 2008 14:02 يونيو 17th ، 2008 14:02
    12

    Thank you. شكرا لك. It works like a charm! وهي تعمل مثل السحر!

  13. Daniel دانيال
    June 18th, 2008 09:34 يونيو 18th ، 2008 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> يمكنك استخدام هذه العلامات : <ahref="" title=""> <abbrtitle=""> <acronymtitle=""> <b><blockquotecite=""> <cite><code><دل datetime = ""> <em><i><qCite=""> <strike><strong>

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 - -- get post ID Wordpress بعد الحصول على رقم تعريف WordPress - -- wordpress page id WordPress رقم تعريف الصفحه - -- $post->ID دولار بعد انتهاء> معرف - -- wordpress $post->id WordPress دولار بعد انتهاء> معرف - -- wordpress the_ID WordPress the_id - -- wordpress current page id WordPress الصفحه الحالية معرف - -- wordpress get id WordPress الحصول على رقم تعريف - -- wordpress get current page id WordPress الحصول على رقم تعريف الصفحه الحالية - -- wordpress post object وجوه ما بعد WordPress - -- wordpress get current page WordPress الحصول على الصفحه الحالية - -- wordpress current post id الوظيفة الحالية WordPress معرف - -- wordpress post_id WordPress post_id - -- page ID wordpress رقم تعريف الصفحه WordPress - -- $post->ID wordpress دولار بعد انتهاء> معرف WordPress - -- wordpress post->ID WordPress ما بعد> معرف - -- wordpress get category id WordPress الحصول على رقم تعريف فئة - -- get post id بعد الحصول على رقم تعريف - -- wordpress if post id WordPress اذا ما بعد الهوية - -- wordpress get post WordPress الحصول على وظيفة - -- wordpress get post by id WordPress الحصول على وظيفة عن طريق كود - -- wordpress post variable WordPress ما بعد المتغير - -- wordpress post variables متغيرات ما بعد WordPress - -- wordpress get current post WordPress الحصول على الوظيفة الحالية - -- wordpress $post object وجوه ما بعد WordPress دولار - -- post id ما بعد الهوية - -- wordpress postid WordPress postid - -- wordpress get current category id WordPress الحالية الحصول على رقم تعريف فئة - -- wordpress $post WordPress دولار بعد - -- post->id بعد انتهاء> معرف - -- wordpress get current post id WordPress الحصول على رقم تعريف الوظيفة الحالية - -- get id wordpress الحصول على رقم تعريف WordPress - -- wordpress get post category id WordPress بعد الحصول على رقم تعريف فئة - -- wordpress $post variable WordPress دولار بعد متغير - -- get post id in wordpress في مرحلة ما بعد الحصول على رقم تعريف WordPress - -- wordpress pageid WordPress معرف الصفحه - -- wordpress get post id outside of loop WordPress بعد الحصول على رقم تعريف من خارج الحلقه - -- get page ID wordpress الحصول على رقم تعريف الصفحه WordPress - -- wordpress the_id() WordPress the_id () - -- wordpress get id of current page WordPress الحصول على رقم تعريف من الصفحه الحالية - -- wordpress get page by id WordPress الحصول على رقم تعريف هذه الصفحه - -- wordpress get latest post WordPress الحصول على أحدث ما بعد - -- wordpress $post_id WordPress دولار post_id - -- wordpress page id outside loop WordPress خارج الحلقه رقم تعريف الصفحه - -- get wordpress post id بعد الحصول على رقم تعريف WordPress - -- wordpress id post WordPress معرف بعد - -- postid wordpress postid WordPress - --