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 में, प्रत्येक पोस्ट न्यूमेरिक पोस्ट के रूप में लंगर अद्वितीय पहचानकर्ता है 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(); ?> ? <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() {
global $post;
$thePostID = $post->ID;
}

or: या:


// Works in single post outside of the Loop
function function_name() {
global $wp_query;
$thePostID = $wp_query->post->ID;
}

$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. पोस्ट $> आईडी लूप के सीधे बाहर बुलाया जा सकता है भी एक पोस्ट में इस तरह के रूप में टेम्पलेट, <php? $ बाद> आईडी गूंज?> मुद्रित है पोस्ट आईडी नंबर प्रदर्शित करेगा.

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 पोस्ट $> आईडी आदेश ए एस सी सीमा 1 post_date द्वारा

//Get the earliest post ID number / / के बाद जल्द से जल्द जाओ संख्या आईडी
$post->ID ORDER BY post_date DESC LIMIT 1 पोस्ट $> आईडी आदेश desc सीमा 1 post_date द्वारा

IMPORTANT : The page is machine translated and provided "as is" without warranty. महत्वपूर्ण: पृष्ठ की मशीन है और अनुवाद प्रदान "के रूप में वारंटी के बिना है." Machine translation may be difficult to understand. मशीन अनुवाद मुश्किल से समझ सकते हो. Please refer to कृपया उल्लेख करने original English article मूल अंग्रेजी लेख whenever possible. जब भी संभव है.


27 Responses to “Retrieve and Get WordPress Post ID Outside the Loop as PHP Variable” 27 उत्तर "और निकालने के लिए PHP परिवर्तनीय के रूप में लूप के बाहर WordPress पोस्ट आईडी जाओ"

Pages: [2] Pages: [2] 1 1 » » Show All सभी दिखाएँ

  1. Konisto Konisto
    November 7th, 2009 03:41 7 नवम्बर 2009 03:41
    27 27

    Hi, नमस्ते,

    I'm trying to modify a custom post-new.php in the admin area and need to access the post_id of a post that I'm currently editing and that has not yet been published. मैं एक कस्टम पोस्ट व्यवस्थापक क्षेत्र में new.php संशोधित करने की कोशिश कर रहा हूँ और एक के बाद post_id का उपयोग कि मैं वर्तमान में संपादन कर रहा हूँ की जरूरत है और यह कि अभी तक प्रकाशित नहीं किया गया है. Any idea how I could do that? किसी भी विचार मैं कैसे कर सकता है?

    Thanks धन्यवाद

  2. Blake ब्लैक
    October 30th, 2009 02:22 30 अक्टूबर 2009 02:22
    26 26

    Thanks, this was super-helpful and easy to understand! धन्यवाद, इस सुपर मददगार और आसानी से समझ रहा था! I love code samples! मैं कोड नमूने प्यार करता हूँ!

Pages: [2] Pages: [2] 1 1 » » Show All सभी दिखाएँ

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=""> <acronym कर सकते हैं <blockquote title=""> <b> cite=""> <cite> <code> <डेल DateTime = ""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. टिप्पणी की सुविधा है विकलांग गया है की सदस्यता लें. To receive notification of latest comments posted, subscribe to सदस्यता के लिए नई टिप्पणियों की सूचना प्राप्त पोस्ट किया है, My Digital Life Comments RSS feed मेरे डिजिटल जीवन टिप्पणियाँ आरएसएस फ़ीड or या register to receive रजिस्टर प्राप्त करने के लिए new comments in daily email digest. दैनिक ईमेल में नई टिप्पणियाँ डाइजेस्ट.
Custom Search

New Articles नए लेख

Incoming Search Terms for the Article के लिए खोजें शर्तें आने अनुच्छेद

wordpress get post id WordPress पोस्ट आईडी मिल - -- wordpress post id WordPress पोस्ट आईडी - -- wordpress get page id WordPress पृष्ठ क्रमांक मिल - -- $post->ID $ बाद> आईडी - -- post id wordpress आईडी WordPress पोस्ट - -- get post id wordpress मिल आईडी WordPress पोस्ट - -- get post id मिल आईडी पोस्ट - -- wordpress get current page id WordPress वर्तमान पृष्ठ क्रमांक मिल - -- wordpress get current post id WordPress वर्तमान पद आईडी मिल - -- wordpress $post->ID $ बाद WordPress> आईडी - -- wordpress get id WordPress आईडी मिल - -- wordpress current page id WordPress वर्तमान पृष्ठ क्रमांक - -- wordpress current post id वर्तमान पद आईडी WordPress - -- $post->ID 104 wordpress पोस्ट $> आईडी 104 WordPress - -- wordpress get id of current page WordPress वर्तमान पृष्ठ की पहचान हो - -- get current post id wordpress वर्तमान पद मिल आईडी WordPress - -- $post->id wordpress पोस्ट $> आईडी WordPress - -- get post id outside loop मिल लूप के बाहर आईडी पोस्ट - -- wordpress current post वर्तमान पद WordPress - -- post id पोस्ट आईडी - -- wordpress get current page WordPress वर्तमान पृष्ठ जाओ - -- wordpress post id outside loop WordPress लूप के बाहर आईडी पोस्ट - -- wordpress get id post WordPress आईडी पद मिल - -- wordpress postid WordPress postid - -- get page id wordpress पृष्ठ क्रमांक WordPress मिल - -- wordpress id post आईडी के बाद WordPress - -- wordpress id WordPress आईडी - -- wordpress get current post WordPress वर्तमान पद मिल - -- wordpress get the post ID WordPress पोस्ट आईडी मिल - -- wordpress get post id outside loop मिल लूप के बाहर आईडी के बाद WordPress - -- wordpress page id variable WordPress पृष्ठ चर आईडी - -- post->ID के बाद> आईडी - -- post- id wordpress बाद आईडी WordPress - -- wordpress php post ID WordPress php पोस्ट आईडी - -- wordpress global post विश्व के बाद WordPress - -- how to get page id in wordpress कैसे WordPress में आईडी पृष्ठ पाने के लिए - -- wordpress latest post id नवीनतम पोस्ट आईडी WordPress - -- wordpress get post by id WordPress द्वारा पोस्ट मिल आईडी - -- get post category wordpress पोस्ट श्रेणी WordPress मिल - -- get current page id wordpress मिल वर्तमान पृष्ठ क्रमांक WordPress - -- wordpress post date outside loop WordPress पोस्ट बाहर की तारीख पाश - -- wordpress find post id WordPress पोस्ट आईडी खोज - -- how to get id php wordpress कैसे आईडी php WordPress पाने के लिए - -- how to get a post id in wordpress in page.php कैसे एक page.php में WordPress में आईडी पद पाने के लिए - -- wordpress get page by id WordPress द्वारा पृष्ठ मिल आईडी - -- get wordpress post ID WordPress पोस्ट मिल आईडी - -- get id wordpress आईडी WordPress मिल - -- post_id wordpress post_id WordPress - -- post id outside loop पोस्ट के बाहर पाश आईडी - -- post info outside loop पोस्ट के बाहर जानकारी पाश - --