WP_Rewrite::get_year_permastruct
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.
Returns
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() WP Rewrite::get year permastruct code WP 7.0
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;
}