Skip to content

Instantly share code, notes, and snippets.

@srikat

srikat/functions.php

Last active Jul 4, 2016
Embed
What would you like to do?
How to automatically change slugs to match titles for Soliloquy sliders. https://sridharkatakam.com/automatically-change-slugs-match-titles-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.