Created
May 30, 2013 05:13
-
-
Save b0n/5675842 to your computer and use it in GitHub Desktop.
wordpress wp_get_archives で指定した月だけ取得する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 月を指定してwp_get_archivesを呼び出します | |
* @see common-sidebar.php | |
* @see wp-includes/general-template.php wp_get_archives() | |
*/ | |
if ( ! function_exists( 'my_custom_post_type_archive_where' ) ) { | |
function my_custom_post_type_archive_where( $where, $args ){ | |
if ($args['type'] != 'monthly') | |
return $where; | |
if (!isset($args['year']) || !is_numeric($args['year'])) | |
return $where; | |
$where .= " AND YEAR(post_date) = '" . $args['year'] . "'"; | |
return $where; | |
} | |
} | |
add_filter( 'getarchives_where', 'my_custom_post_type_archive_where', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment