Created
November 26, 2012 07:05
-
-
Save tobedoit/4146963 to your computer and use it in GitHub Desktop.
Wordpress: non-login user exclude categories
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
/* Non login users Exclude Categories 'author', 'day', 'month', 'year' ************************************************** | |
** http://stackoverflow.com/questions/2789228/exclude-category-from-wp-get-archives ********************************** */ | |
/* !로그인하지 않은 유저, 특정 카테고리 접근 제외 ***************************************************************************** */ | |
function exclude_stuff($query) { | |
if ( !is_user_logged_in() && ( $query->is_day || $query->is_month || $query->is_year || $query->is_author || $query->is_search ) ) { | |
$query->set('cat', '-12, -14'); | |
} | |
elseif ( is_home() ) { // 가장 최근글로부터 sticky 포스트 제거 - http://wordpress.org/support/topic/remove-sticky-posts-from-posts-page | |
$query->set( 'ignore_sticky_posts', true ); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts', 'exclude_stuff'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment