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.
3
Answers
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)This will call the
wp post create
command on each iteration of the loop and append the number to the post title.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: