Retrieve și A lua WordPress Post IDENTITATE Exterior art.hot. Loop as PHP Variabil

Înăuntru WordPress, each post has unique hamsii identifier în format de numeral post Identitate. Cînd interior art.hot. Loop, unde WordPress proces și displays each de la post la spre a fi displayed pe curent pagină și format pe ei acordeon la spre cum ei meciuri specified criteria cu Art.hot. Loop tags, template tag the_ID a putea a fi folosit la easily display art.hot. postIDENTITATE interior art.hot. post. Alternatively, interior art.hot. the_content filter, declare $ identitate global și folos $ identitate la spre retrieve art.hot. post Identitate.

the_ID template tag a putea a fi folosit în a urma format:

<?php the_ID(); ?>

Exterior art.hot. Loop sau afară de la contact de la post, such as înăuntru cap de picior și seară perciuni arie în templates de WordPresss’ blog, the_ID() abil a fi folosit as un funcție. În schimb, $ post-> identitate voință a voi a fi folosit la întoarcere art.hot. post IDENTITATE ( art.hot. syntax a putea de asemenea a fi folosit interior art.hot. Loop de la post by declaring $ post as global). $post is un global object that ținere variabil informații despre art.hot. post displayed pe pagină. So $ post-> identitate voință a voi întoarcere art.hot. post IDENTITATE de la post. It art.hot. $ post is folosit interior un funcție, art.hot. $ post has la spre a fi declared as un global variabil. Pentru example:


Works interior de la Loop
funcție function_name() {
global $ post;
$thePostID = $ post-> identitate;
}

sau:


Works înăuntru singur post exterior de la Loop
funcție function_name() {
global $wp_query;
$thePostID = $wp_query-> post-> identitate;
}

$post-> identitate a putea a fi chemare direct exterior de la Loop de asemenea înăuntru un singur post template, such as <?php echo $ post-> identitate?> voință a voi tipar display art.hot. postIDENTITATE număr.

În multiple post vedere pagină such as a cresta pagină sau arc pagină, săuposibil la spre retrieve art.hot. a lua art.hot. tîrziu sau mai devreme post IDENTITATE de tot art.hot. post displayed pe pagină by folosire un ORDINE BY clause la spre ordine art.hot. post by dată, și apoi atunci a ezat a aranja art.hot. număr de a nota la spre LIMITĂ 1.

Chiar pentru example, și acolo ești variabil way la spre folos art.hot. întrebare:

A lua art.hot. tîrziu post IDENTITATE număr
$post-> identitate ORDINE BY post_date ASC LIMITĂ 1

A lua art.hot. mai devreme post IDENTITATE număr
$post-> identitate ORDINE BY post_date DESC LIMITĂ 1

import: Aceasta este o machine a traduce pagină care is provided "as is" fără warranty. Machine traducere Mai a fi difficult la spre understand. A face pe plac la refer la spreorigine Englez anghinară oricînd posibil.

Share și contribute sau a lua technical cină și ajutor laMeu Digital Viață Forums.



13 Răspuns la spre “Retrieve și A lua WordPress Post IDENTITATE Exterior art.hot. Loop as PHP Variabil

  1. Joel P
    Decembrie 1st, 2006 0606:
    1

    Acesta este într-adevăr bun thing la spre know… I think bolnav’ try la spre folos this cu meu blog și limitat php knowledge.

  2. Matt
    Mai 3rd, 2007 0510:
    2

    Chiar ce I was privire pentru, mulțumiri!

  3. Christofor
    Mai 16th, 2007 1415:
    3

    A întemeia this gît Google. mulțumiri Tu trebiue de asemenea enter this into art.hot. oficial WP documentation wiki: http:/codex.wordpress.org/Main_Page/

  4. k
    Iunie 28th, 2007 1155:
    4

    Mare info. Necesar this cîteva zile în urmă. Voință a voi update meu code cu this sincer approach. Mulțumiri.

  5. Eric
    Septembrie 21st, 2007 0751:
    5

    Mulțumiri, folosireglobal $ identitate;’ înăuntru un filter pentru meu dop luat eu art.hot. post identitate I necesar.

  6. Osordvibil
    Octombrie 6th, 2007 0009:
    6

    comment_fashion

  7. èź©WPäžćŒéĄ”éąäœżç”šäžćŒèźŸèźĄ | æ”¶æ‹Ÿè”·ć€§ćœ°ć±±æČłäž€æ‹…èŁ…
    Octombrie 10th, 2007 2105:
    7

    [...] äœżç”špost IDć˜é‡ćŻä»„ćšćˆ°ă€‚post$->IDćŻä»„èż”ć›žæ–‡ç« çš„ć”Żäž€çŒ–ć·ă€‚ [...]

  8. Copie
    Aprilie 18th, 2008 1811:
    8

    mulțumiri Thats’ chiar ce i sînt privire pentru. I nevoie la spre a lua post identitate pe wordpress a cresta (root) pagină.

  9. Magazin
    Mai 6th, 2008 2002:
    9

    Mulțumiri pentru this. Tu cant believe cum lung it took eu la spre cercetare pentru this simplu answer! I dont know de ce tu cant află it on wordpress.

  10. Johannes
    Iunie 16th, 2008 0327:
    10

    Bună,
    mulțumiri pentru aceștia informații.
    I tried la spre configure ceva fără orice luck și hope tu poți ajută-mă help.
    Im’ folosire wordpress as un blog și a face have cîțiva tablou înăuntru fiecare blog.
    Acum I nevoie la spre implement un feature asemănător shadowbox la spre popular art.hot. imagine. La spre a face this automatically, I a pune un relshadowboximageset=”[]” în hamsii de la imagine.
    Ce a face Eu am la spre a face la spre a pune art.hot. post- titlu sau IDENTITATE în schimbul imagine.
    Is ceva asemănător this posibil?

  11. Johannes
    Iunie 16th, 2008 0327:
    11

    A renunța la Notification de a urma. Mulțumiri.

  12. PieterC
    Iunie 17th, 2008 1402:
    12

    Mulțumesc. It works asemănător un acuzație!

  13. Danez
    Iunie 18th, 2008 0934:
    13

    Mulțumiri pentru this this făcut absolutely ce I necesar la spre a face. :)

Plecare un Reply

Tu poți folos aceștia tags: <un href="" titlu=""> <abbr titlu=""> < vizavi titlu=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> < fibros> < puternic>

A subscrie fără commenting


Custom Search

Nou Anghinară

Incoming Cercetare Terms pentru art.hot. Anghinară

wordpress post identitate - wordpress a lua post identitate - wordpress a lua pagină identitate - post identitate wordpress - a lua post IDENTITATE Wordpress - wordpress pagină identitate - $post-> identitate - wordpress $ post-> identitate - wordpress the_ID - wordpress curent pagină identitate - wordpress a lua curent pagină identitate - wordpress a lua identitate - wordpress post object - wordpress a lua curent pagină - wordpress curent post identitate - wordpress post - pagină IDENTITATE wordpress - wordpress post-> identitate - $post-> identitate wordpress - wordpress a lua category identitate - a lua post identitate - wordpress dacă post identitate - wordpress a lua post - wordpress a lua post by identitate - wordpress $ post - wordpress post variabil - wordpress post variabil - wordpress a lua curent post - post identitate - wordpress $ post object - wordpress post - wordpress a lua curent category identitate - post-> identitate - wordpress a lua curent post identitate - a lua identitate wordpress - wordpress a lua post category identitate - wordpress $ post variabil - a lua post identitate înăuntru wordpress - wordpress pagină - wordpress a lua post identitate exterior de loop - a lua pagină IDENTITATE wordpress - wordpress the_id() - wordpress a lua identitate de curent pagină - wordpress a lua pagină by identitate - post wordpress - wordpress a lua tîrziu post - wordpress exterior art.hot. loop - wordpress $ post - a lua category identitate wordpress - wordpress pagină identitate exterior loop -