Last active
January 22, 2016 19:33
-
-
Save gatespace/7147747 to your computer and use it in GitHub Desktop.
[WordPress] デフォルトのアーカイブウィジェットを特定のカスタム投稿タイプの時のみその投稿タイプのアーカイブにする。要「Custom Post Type Permalinks」プラグイン。
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
| /** | |
| * ウィジェット「アーカイブ」にフィルター | |
| * require Custom Post Type Permalinks | |
| */ | |
| add_filter( 'widget_archives_args', 'my_widget_archives_args', 10, 1); | |
| add_filter( 'widget_archives_dropdown_args', 'my_widget_archives_args', 10, 1); | |
| function my_widget_archives_args( $args ){ | |
| if ( ! is_admin() ) { | |
| if ( 'blog' == get_post_type() ) { | |
| $args['post_type'] = 'blog'; | |
| } | |
| } | |
| return $args; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment