Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wordpress change slug programmatically

// Create post object
$my_post = array(
     'post_title' => 'How to make your diet success',
     'post_name' => '7-ways-to-make-succes-Diet', //This is what set
     'post_content' => 'my content',
     'post_status' => 'publish',
     'post_author' => 1,
     'post_category' => array(8,39)
  );

// Insert the post into the database
$post_id = wp_insert_post( $my_post );

//For updates use this:
wp_update_post([
  "post_name" => "new-slug",
  "ID" => $post_id,
]);
Comment

PREVIOUS NEXT
Code Example
Php :: Laravel check for constraint violation 
Php :: create new record via model in laravel 
Php :: removing the last value of an array 
Php :: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes 
Php :: laravel factory pass parameter 
Php :: php concatenation with a space 
Php :: how to add two string in php 
Php :: php pdo like 
Php :: how remove column in migration laravel 
Php :: php tutorial 
Php :: How do I log properly a Laravel Job 
Php :: woocommerce set default shipping country 
Php :: php xml parser 
Php :: php return multiple values 
Php :: wp_schedule_event 
Php :: get romawi number php 
Php :: Simple factory Design pattern in PHP 
Php :: namecheap shared cpanel change php version for subdomain 
Php :: best custom email validation rule for laravel 
Php :: Generating Random String In PHP Using random_bytes() function. (Cryptographically Secure) 
Php :: php capture include 
Php :: laravel email validation 
Php :: no cache hummingbird 
Php :: include navbar or part in layout in laravel blade template 
Php :: php artisan preset bootstrap 
Php :: Laravel Retrieving & Deleting An Item from session 
Php :: laravel-check-if-related-model-exists 
Php :: php initialize two dimensional array dynamically 
Php :: octobercms mail view 
Php :: how to use model not found exception handler laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =