PHP code example of hellonico / wp-cli-fixtures

1. Go to this page and download the library: Download hellonico/wp-cli-fixtures library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hellonico / wp-cli-fixtures example snippets


 MB_Relationships_API::register( [
        'id'   => 'post_to_term',
        'from'   => 'post',
        'to' => [
            'object_type' => 'term',
            'taxonomy'=> 'custom_term'
        ],
        
    ] );
yaml
Hellonico\Fixtures\Entity\Post:
  my_post:
    __construct: [1] # Pass your post ID as the constructor argument
    post_title: '<sentence()>'
    post_content: '<paragraphs(5, true)>'
    post_excerpt: '<paragraphs(1, true)>'
yaml
Hellonico\Fixtures\Entity\Post:
  post{1..10}:
    __construct: [<postId()>] # Use a custom formatters to return a random post ID as the constructor argument
    post_title: '<sentence()>'
    post_content: '<paragraphs(5, true)>'
    post_excerpt: '<paragraphs(1, true)>'
yaml
Hellonico\Fixtures\Entity\Post:
  post{1..30}:
    post_title: <words(3, true)>
    post_date: <dateTimeThisDecade()>
    meta:
      # number field
      number: <numberBetween(10, 200)>
      meta_box_custom_field: <sentence()>
yaml
Hellonico\Fixtures\Entity\Post:
  post{1..30}:
    post_title: <words(3, true)>
    post_date: <dateTimeThisDecade()>
    mb_relations:
      post_to_term: '1x @custom_term*->term_id'
      post_to_post: '1x @custom_post*->ID'