I am creating post using wp_insert_post(). I would like to insert Post URL at that time. How can I do that ?

enter image description here

  • 2
    the URL of a post isn't stored and used in the database, the only thing a post contributes to its permalink/URL is its name/slug, the rest are derived from WP rewrite rules/global permalink settings. Instead of focusing on how to implement this proposed solution and falling into an X Y problem trap, add details about what the problem is that lead you to this, why would you want this, what does it solve? That context is invaluable for solving your problem
    – Tom J Nowell
    Apr 3 at 9:35

1 Answer 1


When you are using wp_insert_post() there is a param post_name. If you do not pass it then it will sanitise your post title and update.

You only have control to add post_name but the full URL is created based on your Permalink settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.