AbstractBrain Answers About us

WordPress: set new post title and content using URL parameters

Question

WordPress: link to create a new post with pre-filled title and body

In Wordpress you can open the editor to create a new post with this link:

https://example.com/wp-admin/post-new.php

However, is there any way to pre-fill the title and body of the new post? Is it possible to include also HTML in the body?

For example:

https://example.com/wp-admin/post-new.php?title=My title&body=Some text and <b>html tags</b>

Answer

You can pre-fill the title and content of a new post in Wordpress using URL parameters (you don’t need a plugin or custom code for this basic use case).

Here’s the URL that you can use:

https://example.com/wp-admin/post-new.php?post_title=My title&content=Some text

As you can see the important params are post_title and content.

Note that you cannot add HTML tags because they are escaped by Wordpress (so they will be displayed as normal text inside the new post).

You can see the relevant WordPress source code, in particular this line:

$post = get_default_post_to_edit( $post_type, true );