Last active
July 4, 2016 01:59
-
-
Save srikat/cf682e847b0ee43d46e40bc9b9b2ffea to your computer and use it in GitHub Desktop.
How to automatically change slugs to match titles for Soliloquy sliders. https://sridharkatakam.com/automatically-change-slugs-match-titles-soliloquy-sliders/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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