Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active July 4, 2016 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srikat/cf682e847b0ee43d46e40bc9b9b2ffea to your computer and use it in GitHub Desktop.
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/
// 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