WordPress döngü yineleme zaman bu işlevleri değiştirmek küresel değişkenleri kullanır. örneğin:
var $posts = null;
var $post = null;
var $post_count = 0;
var $post_index = 0;
function have_post() {
    global $posts, $post_count, $post_index;
    $post_index = 0;
    // do a database call to retrieve the posts.
    $posts = mysql_query('select * from posts where ...');
    if ($posts) {
        $post_count = count($posts);
        return true;
    } else {
        $post_count = 0;
        return false;
    }
}
function thepost() {
    global $posts, $post, $post_count, $post_index;
    // make sure all the posts haven't already been looped through
    if ($post_index > $post_count) {
        return false;
    }
    // retrieve the post data for the current index
    $post = $posts[$post_index];
    // increment the index for the next time this method is called
    $post_index++;
    return $post;
}
function the_title() {
    global $post;
    return $post['title'];
}
function the_content() {
    global $post;
    return $post['content'];
}
Ben kesinlikle, ancak WordPress ne yaptığını üzerinde cepten tarz kodlama kullanarak öneriyoruz. Bu yerine dünya çapında erişilebilir olmanın bir nesne örneği içinde definied değişkenleri devam edecektir. örneğin:
class Post {
    function __construct($title, $content) {
        $this->title = $title;
        $this->content = $content;
    }
    function getTitle() {
        return $title;
    }
    function getContent() {
        return $content;
    }
}
class Posts {
    var $postCount = 0;
    var $posts = null;
    function __construct($conditions) {
        $rs = mysql_query('select * from posts where $conditions...');
        if ($rs) {
            $this->postCount = count($rs);
            $this->posts = array();
            foreach ($rs as $row) {
                $this->posts[] = new Post($row['title'], $row['content']);
            }
        }
    }
    function getPostCount() {
        return $this->postCount;
    }
    function getPost($index) {
        return $this->posts[$index];
    }
}