PHPackages                             jascha030/wp-post-iterator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jascha030/wp-post-iterator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jascha030/wp-post-iterator
==========================

Simple adapter for the WP\_Query class, built mainly for, but not limited to usage with twig/twig.

0.0.1(4y ago)07GPL-2.0+PHP

Since Apr 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jascha030/wp-post-iterator)[ Packagist](https://packagist.org/packages/jascha030/wp-post-iterator)[ RSS](/packages/jascha030-wp-post-iterator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

WordPress Post Iterator
=======================

[](#wordpress-post-iterator)

A simple adapter, extending WordPress' `\WP_Query` class while implementing PHP's core `Iterator` interface.

Built mainly for, but not limited to usage with the [twig](https://github.com/twigphp/Twig) templating language for PHP.

Getting started
---------------

[](#getting-started)

Prerequisites
-------------

[](#prerequisites)

- Php `^8.0`
- Composer `^2.2` (Not required, but preferred)

### Installation

[](#installation)

Installation instructions, with *examples like the one below*.

```
composer require jascha030/composer-template
```

Usage
-----

[](#usage)

Require the `vendor/autoload.php` file either in your main plugin file, or functions.php, depending on what you are building.

### The most effective way to use it

[](#the-most-effective-way-to-use-it)

The simplest and most effective way to use this package is by using the `PostCollection` class. It's based around Php's IteratorAggregate interface and inspired by (e.g.) Laravel's Collection class and Symfony's Finder and LazyIterator classes.

It provides three static methods to create instances from various types of arguments.

```
