Reputation: 1657
How to set a reasonable permalink on a post created programmatically using wp_insert_post
in Wordpress?
The auto-generated permalink is http://home_url/year/month/.
All auto-generated posts created on the same date end up with the same permalink value.
Upvotes: 0
Views: 822
Reputation: 442
You can't set the permalink on a per-post basis but what I would recommend is changing your WordPress permalink settings to something like:
/%year%/%monthnum%/%day%/%postname%
or remove day /%year%/%monthnum%//%postname%
- Wordpress will add -1, -2, -3 if a title repeats
Aka the date and name based common option in the dashboard.
You can adjust this in the WP admin interface under Settings → Permalinks panel ( or Options → Permalinks before WordPress 2.5)
Reference documentation on the Wordpress.org codex
Upvotes: 2