How to get new post URL?

admin_url('post-new.php');

The admin_url function will handle generating most of the link, you just need to give it the final component. You can pass in GET parameters as well. Just look at the backend URL to see what you need.

admin_url('post-new.php?post_type=page');

Or using add_query_arg as suggested by @Rarst …

add_query_arg(array('post_type'=>'page'),admin_url('post-new.php'));

It is overkill for simple URLs but useful for dynamic ones.

Leave a Comment