Skip to content

Instantly share code, notes, and snippets.



Last active Jul 4, 2016
What would you like to do?
How to automatically change slugs to match titles for Soliloquy sliders.
// Updates slug to match title for Soliloquy sliders
function sk_force_update_slug( $data, $postarr ) {
if ( 'soliloquy' === $postarr['post_type'] && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
$data['post_name'] = sanitize_title( $data['post_title'] );
return $data;
add_filter( 'wp_insert_post_data', 'sk_force_update_slug', 99, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.