lib/Post_Slug.php
public function register_suffix_date( $post_types = [] ) {
		foreach ( $post_types as $post_type => $args ) {
			$this->post_types[ $post_type ] = [
				'callback' => function( $post_slug, $post_data, $post_id ) use ( $args ) {
					$args = wp_parse_args( $args, [
						'meta_key'      => 'date_start',
						'input_format'  => 'Ymd',
						'output_format' => 'Y-m-d',
					] );

					$meta_value = get_post_meta( $post_id, $args['meta_key'], true );

					if ( ! $meta_value ) {
						return $post_slug;
					}

					$date = \DateTime::createFromFormat( $args['input_format'], $meta_value );

					if ( $date ) {
						$post_slug = $post_data['post_title'] . '-'
							. $date->format( $args['output_format'] );
					}

					return $post_slug;
				},
			];
		}
	}
public function register_suffix_date( $post_types = [] ) {
		foreach ( $post_types as $post_type => $args ) {
			$this->post_types[ $post_type ] = [
				'callback' => function( $post_slug, $post_data, $post_id ) use ( $args ) {
					$args = wp_parse_args( $args, [
						'meta_key'      => 'date_start',
						'input_format'  => 'Ymd',
						'output_format' => 'Y-m-d',
					] );

					$meta_value = get_post_meta( $post_id, $args['meta_key'], true );

					if ( ! $meta_value ) {
						return $post_slug;
					}

					$date = \DateTime::createFromFormat( $args['input_format'], $meta_value );

					if ( $date ) {
						$post_slug = $post_data['post_title'] . '-'
							. $date->format( $args['output_format'] );
					}

					return $post_slug;
				},
			];
		}
	}
public function register_suffix_date ( $ post_types = [ ] ) { foreach ( $ post_types as $ post_type => $ args ) { $ this -> post_types [ $ post_type ] = [ 'callback' => function ( $ post_slug , $ post_data , $ post_id ) use ( $ args ) { $ args = wp_parse_args ( $ args , [ 'meta_key' => 'date_start' , 'input_format' => 'Ymd' , 'output_format' => 'Y-m-d' , ] ) ; $ meta_value = get_post_meta ( $ post_id , $ args [ 'meta_key' ] , true ) ; if ( ! $ meta_value ) { return $ post_slug ; } $ date = \ DateTime :: createFromFormat ( $ args [ 'input_format' ] , $ meta_value ) ; if ( $ date ) { $ post_slug = $ post_data [ 'post_title' ] . '-' . $ date -> format ( $ args [ 'output_format' ] ) ; } return $ post_slug ; } , ] ; } }
Registers date suffixes for post slugs.

@param array $post_types An associative array of post types and their suffix args.
Registers date suffixes for post slugs .