Set title and slug of new post using URL parameters
-
Just as previously asked here:
Is it possible to generate a
post-new.php
URL that prefills some fields of the new post edit screen?Something like:
/
wp-admin/post-new.php?post_type=custom-post-type&title=CustomTitle&slug=custom_slug
I’m registering using admin notices when a shortcode is being used but it cannot load what it requires because the associated post doesn’t exist yet.
For example:[post_title slug="custom_slug"]
(Don’t ask why am I not using ID, just go with it, this is just an example and not the real scenario)So when I detect that the shortcode is being used and it cannot load the post title because there is no post yet with the provided slug, I add an admin notice with a link so that the user can either edit the page where the shortcode is used to fix it and a link that allows the user to create the missing post, prefilling the necessary fields (title and slug).
We assume that the user may not be smart enough to know which slug they need to create, so we need to prefill it for them.
- The topic ‘Set title and slug of new post using URL parameters’ is closed to new replies.