PHPackages                             mehrshaddarzi/wp-cli-fixtures - 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. mehrshaddarzi/wp-cli-fixtures

ActiveWp-cli-package[Utility &amp; Helpers](/categories/utility)

mehrshaddarzi/wp-cli-fixtures
=============================

Easily generate fake data for WordPress

0.3.0(6y ago)03GPL-3.0+PHP

Since Nov 24Pushed 4y agoCompare

[ Source](https://github.com/mehrshaddarzi/wp-cli-fixtures)[ Packagist](https://packagist.org/packages/mehrshaddarzi/wp-cli-fixtures)[ Docs](https://github.com/nlemoine/wp-cli-fixtures)[ RSS](/packages/mehrshaddarzi-wp-cli-fixtures/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (10)Used By (0)

wp-cli-fixtures
===============

[](#wp-cli-fixtures)

[![GitHub Workflow Status](https://camo.githubusercontent.com/6209bbaf910bd2ab67435eccd3e2140c5527744ca1c8834ffd2794bb78fab109/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6e6c656d6f696e652f77702d636c692d66697874757265732f54657374696e673f7374796c653d666c61742d737175617265)](https://github.com/nlemoine/wp-cli-fixtures/actions/workflows/testing.yml?query=branch%3Amaster+workflow%3ATesting)[![Packagist Downloads](https://camo.githubusercontent.com/5ab652b840f8405759676a8d6ca4e8a752eaf31231fd980c622a241da45ecbc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68656c6c6f6e69636f2f77702d636c692d66697874757265733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/5ab652b840f8405759676a8d6ca4e8a752eaf31231fd980c622a241da45ecbc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68656c6c6f6e69636f2f77702d636c692d66697874757265733f7374796c653d666c61742d737175617265)[![Packagist PHP Version Support](https://camo.githubusercontent.com/87b5cfc5e318d7eaaa3ec5621516464730abb328c54792c64ee3cdecc9ded2bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f68656c6c6f6e69636f2f77702d636c692d66697874757265733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/87b5cfc5e318d7eaaa3ec5621516464730abb328c54792c64ee3cdecc9ded2bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f68656c6c6f6e69636f2f77702d636c692d66697874757265733f7374796c653d666c61742d737175617265)

Inspired by [Faker](https://github.com/trendwerk/faker), this package provides an easy way to create massive and custom fake data for your WordPress installation. This package is based on [nelmio/alice](https://github.com/nelmio/alice) and [fzaninotto/Faker](https://github.com/fzaninotto/Faker). Please refer to these packages docs for advanced usage.

[![wp-cli-fixtures demo](https://camo.githubusercontent.com/c75c79091595e4c68b7d52ae2d404bfa58ae8398e7b51d3bdd3a48b987827fd5/68747470733a2f2f68656c6c6f6e69636f2e73332e65752d776573742d312e616d617a6f6e6177732e636f6d2f6465762f77702d636c692d66697874757265732e676966)](https://camo.githubusercontent.com/c75c79091595e4c68b7d52ae2d404bfa58ae8398e7b51d3bdd3a48b987827fd5/68747470733a2f2f68656c6c6f6e69636f2e73332e65752d776573742d312e616d617a6f6e6177732e636f6d2f6465762f77702d636c692d66697874757265732e676966)

**WARNING:** This package is mostly intented to be used for development purposes. Use it at your own risk, don't run it on a production database or make sure to back it up first.

Quick links: [Install](#install) | [Usage](#usage) | [Contribute](#contribute)

Install
-------

[](#install)

```
wp package install https://github.com/mehrshaddarzi/wp-cli-fixtures/archive/refs/heads/master.zip
```

Requires PHP `^7.3`.

Usage
-----

[](#usage)

### Create fixtures

[](#create-fixtures)

At the root of your project, create a `fixtures.yml` file (you can download it [here](https://raw.githubusercontent.com/mehrshaddarzi/wp-cli-fixtures/master/examples/fixtures.yml)):

```
#
# USERS
#
Hellonico\Fixtures\Entity\User:
  user{1..10}:
    user_login (unique):  # '(unique)' is required
    user_pass: 123
    user_email:
    user_url:
    user_registered:
    first_name:
    last_name:
    description:
    role:
    meta:
      show_admin_bar_front: 'false'
      billing_phone:
      billing_country: 'IR'
      billing_state:
      billing_city:
      billing_address_1:
      billing_postcode:
      billing_email: '@self->user_email'
      billing_first_name: '@self->first_name'
      billing_last_name: '@self->last_name'
    acf:
      facebook_url:
      twitter_url:

#
# ATTACHMENTS
#
Hellonico\Fixtures\Entity\Attachment:
  default (template):
    post_title:
    post_date:
    post_content:
  pics{1..3} (extends default):
    file:
  documents{1..2} (extends default):
    file:
  custom_images{1..4} (extends default):
    file:

#
# TERMS
#
Hellonico\Fixtures\Entity\Term:
  category{1..10}:
    name (unique):  # '(unique)' is required
    description:
    parent: '50%? ' # 50% of created categories will have a top level parent category
    taxonomy: 'category' # could be skipped, default to 'category'
  tag{1..5}:
    name (unique):  # '(unique)' is required
    description:
    taxonomy: 'post_tag'
  product_cat{1..5}: # custom taxonomy
    name (unique):  # '(unique)' is required
    description:
    taxonomy: 'product_cat'
    acf:
      address:
      zip:
      city:
      image: '@custom_images*->ID'

#
# POSTS
#
Hellonico\Fixtures\Entity\Post:

  # TEMPLATE
  defaultpost (template):
    post_title:
    post_date:
    post_content:
    post_excerpt:

  # POSTS
  post{1..30} (extends defaultpost):
    meta:
      _thumbnail_id: '@custom_images*->ID'
    meta_input:
      _extra_field:
    post_category: '3x @category*->term_id' # post_category only accepts IDs
    tax_input:
      post_tag: '2x @tag*->term_id'
      # post_tag: '5x  # Or tags can be dynamically created

  # PAGES
  page{contact, privacy} (extends defaultpost):
    post_title:
    post_type: page

  # CUSTOM POST TYPE
  product{1..15} (extends defaultpost):
    post_type: product
    meta:
      _thumbnail_id: '@custom_images*->ID'
    meta_input:
      _sku:
      _price:
      _stock_status: 'instock'
      _manage_stock: 'yes'
      _stock:

#
# COMMENTS
#
Hellonico\Fixtures\Entity\Comment:
  comment{1..50}:
    comment_post_ID: '@post*->ID'
    user_id: '@user*->ID'
    comment_date:
    comment_author:
    comment_author_email:
    comment_author_url:
    comment_content:
    comment_agent:
    comment_author_IP:
    comment_approved: 1
    comment_karma:
    # 'meta' and 'comment_meta' are basically the same, you can use one or both,
    # they will be merged, just don't provide the same keys in each definition
    comment_meta:
      some_key:
    meta:
      another_key:

#
#  NAV MENUS
#
Hellonico\Fixtures\Entity\NavMenu:
  header:
    name: header
    locations:
      - header
      - footer

#
#  NAV MENUS ITEMS
#
Hellonico\Fixtures\Entity\NavMenuItem:
  custom_menu:
    menu_item_url:
    menu_item_title:
    menu_id: '@header->term_id'
  categories{1..3}:
    menu_item_object: '@category*'
    menu_id: '@header->term_id'
  posts{1..3}:
    menu_item_object: '@post*'
    menu_id: '@header->term_id'
  page:
    menu_item_object: '@page*'
    menu_id: '@header->term_id'
```

The example above will generate:

- 10 users
- 15 attachments
- 10 categories
- 40 tags
- 30 posts with a thumbnail, 3 categories and 5 tags
- 10 pages
- 15 custom post types named 'product'
- 50 comments associated with post and user
- 1 nav menu
- 6 nav menu items

**IMPORTANT:** Make sure referenced IDs are placed **BEFORE** they are used.

Example: `Term` or `Attachment` objects **must** be placed before `Post` if you're referencing them in your fixtures.

### Load fixtures

[](#load-fixtures)

```
wp fixtures load

```

You can also specify a custom file by using the `--file` argument:

```
wp fixtures load --file=data.yml

```

### Delete fixtures

[](#delete-fixtures)

```
wp fixtures delete

```

You also can delete a single fixture type:

```
wp fixtures delete post

```

Valid types are `post`, `attachment`, `comment`, `term`, `user`.

### Add fake data to existing content

[](#add-fake-data-to-existing-content)

`wp-cli-fixtures` allows you to add/update content to existing entities by passing the ID as a constructor argument.

Add/update data to post ID 1:

```
Hellonico\Fixtures\Entity\Post:
  my_post:
    __construct: [1] # Pass your post ID as the constructor argument
    post_title: ''
    post_content: ''
    post_excerpt: ''
```

Add/update data to 10 random existing posts:

```
Hellonico\Fixtures\Entity\Post:
  post{1..10}:
    __construct: [] # Use a custom formatters to return a random post ID as the constructor argument
    post_title: ''
    post_content: ''
    post_excerpt: ''
```

### Entities

[](#entities)

#### Post

[](#post)

`Hellonico\Fixtures\Entity\Post` can take any parameters available in [`wp_insert_post`](https://developer.wordpress.org/reference/functions/wp_insert_post/#parameters) + `meta` and `acf` key.

*Note: `post_date_gmt` and `post_modified_gmt` have been disabled, there are set from `post_date` and `post_modified`.*

#### Attachment

[](#attachment)

`Hellonico\Fixtures\Entity\Attachment` can take any parameters available in [`wp_insert_attachment`](https://developer.wordpress.org/reference/functions/wp_insert_attachment/#parameters) + `meta`, `file` and `acf` custom keys.

*Note: `parent` must be passed with `post_parent` key.*

#### Term

[](#term)

`Hellonico\Fixtures\Entity\Term` can take any parameters available in [`wp_insert_term`](https://developer.wordpress.org/reference/functions/wp_insert_term/#parameters) + `meta` and `acf` custom keys.

*Note: `term` and `taxonomy` must be respectively passed with `name` and `taxonomy` key.*

#### User

[](#user)

`Hellonico\Fixtures\Entity\User` can take any parameters available in [`wp_insert_user`](https://developer.wordpress.org/reference/functions/wp_insert_user/#parameters) + `meta` and `acf` custom keys.

#### Comment

[](#comment)

`Hellonico\Fixtures\Entity\Comment` can take any parameters available in [`wp_insert_comment`](https://developer.wordpress.org/reference/functions/wp_insert_comment/#parameters) + `meta` custom key.

`comment_date_gmt` has been disabled, it is set from `comment_date`.

#### Nav menu

[](#nav-menu)

`Hellonico\Fixtures\Entity\NavMenu` is a term just like `Hellonico\Fixtures\Entity\Term`. It takes an addiotional `locations` parameter to set the menu location.

```
Hellonico\Fixtures\Entity\NavMenu:
  header:
    name: header
    locations:
      - header
```

#### Nav menu item

[](#nav-menu-item)

`Hellonico\Fixtures\Entity\NavMenuItem` takes the same parameters as `$menu_item_data` in [`wp_update_nav_menu_item`](https://developer.wordpress.org/reference/functions/wp_update_nav_menu_item/#parameters)

*Note 1: replace dashes with underscore in keys (e.g. `menu-item-object` becomes `menu_item_object`).*

*Note 2: `menu-item-object` can also accept an entity object, if so, `menu-item-type` and `menu-item-object-id` will be filled automatically with appropriate values*

### ACF Support

[](#acf-support)

Each ACF supported entity (post, term, user) can have an `acf` key, which works just like `meta`.

```
Hellonico\Fixtures\Entity\Post:
  post{1..30}:
    post_title:
    post_date:
    acf:
      # number field
      number:
      # repeater field
      features:
        - label:
          value:  You will need to run `composer run prepare-tests` before your first run.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~209 days

Recently: every ~312 days

Total

7

Last Release

2200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b468d7958e961014f669dbba52acfdec695c5c200792c4f4d85f8131d8a99c0c?d=identicon)[mehrshaddarzi](/maintainers/mehrshaddarzi)

---

Top Contributors

[![nlemoine](https://avatars.githubusercontent.com/u/2526939?v=4)](https://github.com/nlemoine "nlemoine (61 commits)")[![mehrshaddarzi](https://avatars.githubusercontent.com/u/949491?v=4)](https://github.com/mehrshaddarzi "mehrshaddarzi (8 commits)")

### Embed Badge

![Health badge](/badges/mehrshaddarzi-wp-cli-fixtures/health.svg)

```
[![Health](https://phpackages.com/badges/mehrshaddarzi-wp-cli-fixtures/health.svg)](https://phpackages.com/packages/mehrshaddarzi-wp-cli-fixtures)
```

###  Alternatives

[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
