wordpress get page slug
// Get the queried object and sanitize it
$current_page = sanitize_post( $GLOBALS['wp_the_query']->get_queried_object() );
// Get the page slug
$slug = $current_page->post_name;
wordpress get page slug
// Get the queried object and sanitize it
$current_page = sanitize_post( $GLOBALS['wp_the_query']->get_queried_object() );
// Get the page slug
$slug = $current_page->post_name;
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,
]);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us