Skip Navigation

[Gelöst] custom title – update slug

This support ticket is created vor 5 Jahre, 3 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 Antworten, has 2 Stimmen.

Last updated by Akhil vor 5 Jahre, 3 Monate.

Assisted by: Waqar.

Author
Artikel
#1185774

Hi Waqar, still working on the custom title. all look good now,. except the slug is not updated when i click the 'update' button.

i understand this code will re-create the slug, but it doesn't for my case.

$slug = sanitize_title($title);

Do you see any issue ?

i insert it right after ..

.....
$data['post_title'] = $title ;
$slug = sanitize_title($title);
//Updates the post title to your new title.
}
return $data;

#1186010

Waqar
Supporter

Languages: Englisch (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Dee,

Thanks for asking! I'd be happy to help.

The "sanitize_title" prepares the string to be used as part of the URL ( ref: https://codex.wordpress.org/Function_Reference/sanitize_title ) but doesn't actually saves it as a slug.

You'll need to tell your function to use the sanitized title value as a "post_name" (slug) and your code will become:


.....
// update the title
$data['post_title'] = $title ;

// update the slug (same as the title, but sanitized)
$data['post_name'] =  sanitize_title($title) ;

}
return $data;

I hope this helps!

regards,
Waqar

#1188217

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.