You can use post_name
parameter.
$my_post = array(
'post_title' => wp_strip_all_tags( $_POST['post_title'] ),
'post_content' => $_POST['post_content'],
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array( 8,39 ),
'post_name' => 'your-url'
);
wp_insert_post( $my_post );
Related Posts:
- Backup the Database and Restore from the Backup?
- Scaling a WP eCommerce site
- Looking for a lightweight theme using WP3 new tags and features (not 2010) [closed]
- Limit Media Library to Given Folder
- How can I get posts in a subcategory to display on it’s parent categories archive page?
- Creating my own Admin Forms in a WordPress CMS?
- Custom taxonomy: same terms, but for different years
- customize_register with Multiple controls/settings – how to get values?
- Best practices for A/B testing?
- Editing the Number at the end of Page URLs / Editing Page Slugs
- Integrating the WordPress admin panel with a frontend theme
- simple wp_insert_post example
- Redirect members to custom page upon logging in through WP admin
- Can I use $wpdb for my custom tables in the WordPress database?
- Integrating MailChimp newsletters as post
- What is WordPress file encoding?
- WP_Query with the “offset” argument
- Adding “Interesting Tags” & “Ignored Tags” like StackOverflow.com in a WordPress Blog?
- Auto add taxonomy if post has category
- Add a containing DIV to core Gutenberg blocks
- Allow comments without approval for custom content type
- Are there any security issues with setting the WP_INSTALLING constant to true?
- Naming script handles right way
- How to add classes in the wp_list_category parent link
- WordPress generated links – menus and home_url() – not using https despite settings
- How to use
- Name/Word Replacement Plugin
- Get page ID outside the loop, matching menu ID
- Author Tracking Code!
- Viewing checkout page removes fees from mini cart
- help to change some colors (woocomerce and store locator) [closed]
- Show Featured Post Only On The Homepage
- How can I create a second multisite network in a subdirectory?
- How do i remove animated icon [closed]
- Lost password empty field error redirect to custom login
- Custom comments list, right depth
- Order posts with a custom field but also without
- How to hook up search results page to a back-end page?
- WordPress Custom File Permalink
- WordPress 3.0.1 on IIS 6 Web Server PermaLink Issues
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- how to display a specific wordpress menu?
- Create a url structure for my blogs based on categories and sub-cats
- Widgets won’t save
- Change Notice of Password change email subject?
- Deleting my old WordPress site. – issues
- Dynamically Filtering Posts by Data Points – Any Pointers?
- Woocommerce custom checkout form
- Remove year from title
- Custom Tags Archive – permalinks not working
- How to append custom text to the output of ‘categories widget’?
- Centering one product on a single page [closed]
- Remove link from page title
- How to assign a custom post title to be the post ID?
- Creating custom page template
- Which delete query is better with prepare or delete
- Change Site Logo or Menu Logo Per Page
- How to add page content into another page
- Localhost wordpress access remote db wordpress website
- add_action does not work when instance multiple tab-containers via template-file
- Remove Sidebars from page
- accessing monthly archive from dashboard
- WordPress 3.1.2 Bug: add_theme_support() and video post format registering twice
- WP Search Form Query: Add Author’s posts into search query
- Creating a “Delete”-Button for Metadata userspecific
- Change default Video Player without Plugin
- Changing update message from Newspaper child theme
- Custom default settings for WP native Gallery Block
- export and import wordpress customization
- where is admin footer?
- How can i add customisation of text to my theme?
- Can I overwrite custom taxonomy FROM “public” TO “false”
- Trying to customise 2011 Child Theme Background Colour
- New Page/Post Screen Opens an Existing Post
- Custom product status get filtered on all product list views
- the temporary save folder is wrong
- URL issue after setting up Custom Structure in Settings >> Permalinks
- Can I upload my self hosted WordPress website on GitHub as a project? [closed]
- Need to replace some text string on a title
- Custom roles and capabilities media not work right
- Create single{custom}.php with data in table out of wp_posts
- How do i edit text that is not in the customization menu
- How do I map two domains to the same wordpress installation?
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Where should I put this custom data?
- Changing starting number of User ID
- how to register / add multiple options into one field in wordpress?
- Custom WP deactivate an email activation link sent to user’s email.
- How to duplicate “Pages” section in the control panel?
- WordPress Customize panel – accessing the values
- Page template with custom html fields inside a content
- Show post content in two different places without redirect
- Multiple Customizers
- how do i add logo in my site
- Show total sales for each products on search results page Woocommerce
- Changes to code not displaying
- Permalink Listing WordPress
- Has the table name in SQL for WordPress changed from WP_posts to WPCS_post?
- Multi color post title by using custom javascript inside the gutenberg editor?
- Add custom styles to the Raft theme