IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

WordPress PHP Discussion :

Comment fonctionne la fonction the_post() de wordpress ?


Sujet :

WordPress PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 14
    Par défaut Comment fonctionne la fonction the_post() de wordpress ?
    Bonjour

    Dans wordpress pour afficher les articles ont utilise la fonction : have_post().
    En regardant dans les lignes de code je m'aperçois qu'elle est définie comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    function the_post() {
    	global $wp_query;
     
    	$wp_query->the_post();
    }
    Je n'arrive pas à comprendre comment elle marche.
    Si quelqu'un connait le fonctionnement de wordpress ...

    Cordialement

  2. #2
    Membre expérimenté
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    336
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 336
    Par défaut
    Bonsoir,

    si tu comprends l'anglais, tu trouveras ton bonheur ici : http://codex.wordpress.org/The_Loop

    En particulier, vers le milieu de la page :

    An explanation for the coders out there: The have_posts() and the_post() are convenience wrappers around the global $wp_query object, which is where all of the action is. The $wp_query is called in the blog header and fed query arguments coming in through GET and PATH_INFO. The $wp_query takes the arguments and builds and executes a DB query that results in an array of posts. This array is stored in the object and also returned back to the blog header where it is stuffed into the global $posts array (for backward compatibility with old post loops).

    Once WordPress has finished loading the blog header and is descending into the template, we arrive at our post Loop. The have_posts() simply calls into $wp_query->have_posts() which checks a loop counter to see if there are any posts left in the post array. And the_post() calls $wp_query->the_post() which advances the loop counter and sets up the global $post variable as well as all of the global post data. Once we have exhausted the loop, have_posts() will return false and we are done.

    Karl3i.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 14
    Par défaut
    merci

Discussions similaires

  1. [interp2] Comment fonctionne cette fonction ?
    Par rom3478 dans le forum MATLAB
    Réponses: 3
    Dernier message: 03/11/2010, 21h39
  2. Réponses: 3
    Dernier message: 20/06/2008, 13h20
  3. Comment fonctionne la fonction find en perl
    Par lavm01 dans le forum Langage
    Réponses: 2
    Dernier message: 10/01/2008, 17h28
  4. Comment fonctionne la fonction mahal ?
    Par leFeu dans le forum Traitement d'images
    Réponses: 1
    Dernier message: 09/01/2008, 16h35
  5. [ImageMagick] Comment fonctionne la fonction imagefttext ?
    Par Dsphinx dans le forum Bibliothèques et frameworks
    Réponses: 7
    Dernier message: 30/11/2006, 11h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo