WP_Rewrite::get_year_permastruct()publicWP 1.5.0

Retrieves the year permalink structure without month and day.

Gets the date permalink structure and strips out the month and day permalink structures.

Method of the class: WP_Rewrite{}

No Hooks.

Return

String|false. Year permalink structure on success, false on failure.

Usage

global $wp_rewrite;
$wp_rewrite->get_year_permastruct();

Changelog

Since 1.5.0 Introduced.

WP_Rewrite::get_year_permastruct() code WP 6.4.3

public function get_year_permastruct() {
	$structure = $this->get_date_permastruct();

	if ( empty( $structure ) ) {
		return false;
	}

	$structure = str_replace( '%monthnum%', '', $structure );
	$structure = str_replace( '%day%', '', $structure );
	$structure = preg_replace( '#/+#', '/', $structure );

	return $structure;
}