Monthly Archives: June 2015

As seen on a postcard

I’m not sure how they got the site to generate filler in pen, but it’s a cool trick.  😉

 

 

Posted in Blog | Leave a comment

Updates to the API

We have some new updates to the Bacon Ipsum API:

New formats: ‘text’ and ‘html’ if you need responses in something other than the default JSON format.  Ex: https://baconipsum.com/api/?type=all-meat&start-with-lorem=1&format=html (Thanks to Shawn Hooper for new formats).

Ranges for paragraphs: Need to generate a random number of paragraphs?  We support that now, just put the range in the paras parameter, ex: paras=3-7  https://baconipsum.com/api/?type=all-meat&start-with-lorem=1&paras=3-7

These same updates have been made to the Any Ipsum WordPress plugin.

Posted in Blog | Tagged | Leave a comment

Bulk generating WordPress posts with filler content using WP-CLI and the Bacon Ipsum API

I recently attended WordCamp Miami and Shawn Hooper gave an excellent talk on using the WordPress command-line interface (WP-CLI) to manage your WordPress install.  One of the items he covered was bulk generating posts so you have some initial content to use when developing a new theme or other functionality.  Check out all the slides on his site.

Using the “wp post generate” command, you can have WordPress bulk generate a specific number of posts.  By default, these posts are empty, but by including a curl command to the Bacon Ipsum API, you can have the posts automatically filled with Bacon Ipsum filler content.

curl "https://baconipsum.com/api/?type=meat-and-filler&paras=5&format=html" | wp post generate --count=50 --post_content

The one drawback to this method is the results of the API call are used for every post, so each post has the same filler content.  However, using a “for” loop in the terminal, we can generate unique filler content for each post.  It takes longer to generate the posts, but you will get unique content.  For example, this will generate five posts with unique content.

for n in {1..5}; do curl "https://baconipsum.com/api/?type=all-meat&paras=5&format=html" | wp post generate --count=1 --post_content; done

You’ll get output that looks something like this.

bacon-ipsum-api-wp-cli-bulk-generate-posts

I’m also thinking of adding range values or a ‘random’ parameter to the API so you can get content of varying lengths, such as 1-5 paragraphs instead of always a fixed length.

FYI, Shawn also contributed code to the Any Ipsum plugin at the beginning of WordCamp Miami to allow the API to return text or HTML instead of just JSON so he could use it in his talk.  It’s really great to be able to incorporate a new feature right away and many thanks to Shawn for the new features.

 

Posted in Blog | 2 Comments