JayWood / jw-wpcli-random-posts

A robust random post generator for WP CLI which supports multisite, post types, post counts, taxonomies, terms, term counts and featured images. Complete with a cleanup command to undo it all!
http://plugish.com
57 stars 8 forks source link

A bunch of warnings are shown when creating posts #15

Closed andreasciamanna closed 5 years ago

andreasciamanna commented 6 years ago

As promised in #9, I'm going to report an issue with generating posts.

The used command is wp jw-random generate 10 --featured-image --tax=category,post_tag --tax-n=15 --img-type=abstract.

This produces a bunch of warnings (more than the number of generated posts):

Warning: Received an error inserting The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. term into the post_tag taxonomy: A term with the name provided already exists in this taxonomy.

andreasciamanna commented 6 years ago

It looks like the content of the warning is used to populate taxonomy terms (???): image

phatsk commented 6 years ago

+1 Ran into the same issue just now from master. I might try to dig into this later.

rovente commented 5 years ago

+1 Same issue for me, would be great if anyone can fix it

rovente commented 5 years ago

The taxonomy terms are populated with text generated by this tool, no longer working: https://setgetgo.com/randomword/get.php

So this is my fix, replace the function get_term() in line 495 of generate-posts.php with this:

private function get_term() { $request = wp_safe_remote_get( 'http://www.filltext.com/?rows=1&text={lorem|'.rand(1,2).'}' ); if ( is_wp_error( $request ) ) { WP_CLI::warning( sprintf( 'Error getting a random word for a term: %s', $request->get_error_message() ) ); return ''; } $json = json_decode(str_replace(array('[',']'), '', $request['body'])); return $json->{'text'}; }

The terms generated are randomly 1-2 words get using http://www.filltext.com API

JayWood commented 5 years ago

This is resolved with the latest release, sorry everyone!