Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GOOD domain/cartoon-series/<series-name1>/episodes/<episode-name>
- GOOD domain/cartoon-series/<series-name2>/episodes/<episode-name>
- BAD domain/cartoon-series/<series-name2>/episodes-1/<episode-name>
- //Automatically creates a category in the case log and adds it to the post.
- function add_title_as_category( $postid ) {
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
- $post = get_post($postid);
- if ( $post->post_type == 'case') { // change 'post' to any cpt you want to target
- $term = get_term_by('slug', $post->post_name, 'case-log');
- if ( empty($term) ) {
- $add = wp_insert_term( $post->post_title, 'case-log', array('slug'=> $post->post_name) );
- if ( is_array($add) && isset($add['term_id']) ) {
- wp_set_object_terms($postid, $add['term_id'], 'case-log', true );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement