Home > Software engineering >  How do I generate numeric titled wordpress posts?
How do I generate numeric titled wordpress posts?

Time:01-16

I would like to automatically generate some sequential Wordpress posts that have numeric titles, for example "1", "2", "3"... etc.

I'm looking for an automatic system since I would like my posts to go from "1" to "999999".

No post content or meta is required, only the titles.

I'm aware of wp post generate but I have no idea on how to use it so that the post titles have the requirements explained above.

I'm working on a demo project so search engine optimization is not a concern at the moment.

CLI usage is accepted.

CodePudding user response:

You can achieve that quite simply by using a for loop with any arbitrary range (1-99 for example - or any other range you prefer)

for i in {1..99}; do wp post create --post_title="This is post number $i" --post_status=publish; done

This will call the wp post create command on each iteration of the loop and append the number to the post title.

CodePudding user response:

wordpress appends a numeric value automatically if there's an existing post with the same post-title.

so if the permalinks are set to be postname the URL will look as follow:

my-post
my-post-1
my-post-2
etc
  • Related