Skip to content

Instantly share code, notes, and snippets.

View tobedoit's full-sized avatar

James You tobedoit

View GitHub Profile
@tobedoit
tobedoit / gist:4147001
Created November 26, 2012 07:18
Wordpress: sticky posts arrange first in category archive
<?php } elseif ( is_category('6') ) { // !카테고리 공지사항 ?>
<?php // get the current category
$category = get_the_category();
// get the sticky post in the category
query_posts(array( 'post__in' => get_option('sticky_posts'), 'cat' => ''.$category[0]->cat_ID.'' ));
if (have_posts()) : while (have_posts()) : the_post();
get_template_part('includes/entry', 'index');
endwhile; endif;
@tobedoit
tobedoit / gist:4146983
Created November 26, 2012 07:13
Wordpress: login redirect to current page
<form action='<?php echo wp_login_url( $_SERVER['REQUEST_URI'] ); ?>' method='post'>
@tobedoit
tobedoit / gist:4146965
Created November 26, 2012 07:05
Wordpress: change footer text in admin panel
/* Change footer text in WordPress admin panel **************************************************
** http://www.instantshift.com/2012/03/06/21-most-useful-wordpress-admin-page-hacks/ ********* */
/* !관리자 페이지 푸터 카피라이트 변경 ************************************************************** */
function remove_footer_admin () {
echo '상록수장학재단을 찾아주셔서 감사합니다.';
}
add_filter('admin_footer_text', 'remove_footer_admin');
@tobedoit
tobedoit / gist:4146963
Created November 26, 2012 07:05
Wordpress: non-login user exclude categories
/* 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 );
}
@tobedoit
tobedoit / gist:4146957
Created November 26, 2012 07:04
Wordpress: remove post write panel features
/* Remove page and post write panel features **********************************************************************
** http://wpmu.org/remove-page-and-post-write-panel-features/ *****************************************************
** http://wordpress.stackexchange.com/questions/2025/removing-metabox-for-slug-without-removing-functionality ** */
/* !관리자외 글쓰기 패널 삭제 *************************************************************************************** */
add_action('admin_init', 'my_custom_write_panel');
function my_custom_write_panel() {
//if ( !current_user_can( 'delete_others_posts' ) ) { // if user is below Editor level
//if ( !current_user_can( 'manage_options' ) ) { // if user is below Administrator level
remove_post_type_support( 'post', 'excerpt' );
remove_post_type_support( 'post', 'custom-fields' );
@tobedoit
tobedoit / gist:4146952
Created November 26, 2012 07:03
Wordpress: remove 'media' and 'tool' menu
/* Remove 'Media' and 'Tool' menus for non admin users *******************************************
** http://www.instantshift.com/2012/03/06/21-most-useful-wordpress-admin-page-hacks/ ********** */
/* !관리자외 미디어 메뉴 삭제 ********************************************************************** */
add_action( 'admin_menu', 'remove_links_menu' );
function remove_links_menu() {
//if (!current_user_can('manage_options')) { // if user is below Administrator level
remove_menu_page('upload.php'); // Media
remove_menu_page('tools.php'); // Tools
remove_menu_page('link-manager.php'); // Tools
//}
@tobedoit
tobedoit / gist:4146948
Created November 26, 2012 07:01
Wordpress: display current user role
/* Display Current User Role *************************************************************************** */
/* http://wordpress.org/support/topic/how-to-get-the-current-logged-in-users-role ********************** */
/* !로그인 회원역할 표시 *********************************************************************************** */
/* <?php echo get_current_user_role(); ?> in your template ******************************************** */
function get_current_user_role() {
global $wp_roles;
$current_user = wp_get_current_user();
$roles = $current_user->roles;
$role = array_shift($roles);
return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : false;
@tobedoit
tobedoit / gist:4146945
Created November 26, 2012 07:01
Wordpress: Role and Capability
/* 'Role' name change ********************************************************************************************
** http://wordpress.stackexchange.com/questions/23026/is-there-way-to-rename-user-role-name-without-plugin **** */
/* !회원 역할 이름 바꾸기 ***************************************************************************************** */
function change_role_name() {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
//You can list all currently available roles like this...
@tobedoit
tobedoit / gist:4146942
Created November 26, 2012 06:59
Wordpress: remove the "Dashboard" and redirect for non-admin user
/* Remove the "Dashboard" from the admin menu for non-admin users **********************************
** http://wordpress.stackexchange.com/questions/52752/hide-dashboard-from-non-admin-users ******* */
/* !관리자 아닌 회원 알림판 제거 & 리다이렉트 *********************************************************** */
function custom_remove_dashboard () {
global $current_user, $menu, $submenu;
get_currentuserinfo();
if( ! in_array( 'administrator', $current_user->roles ) ) {
reset( $menu );
$page = key( $menu );
@tobedoit
tobedoit / gist:4146927
Created November 26, 2012 06:54
Wordpress: customize toolbar
/* Customize Toolbar **************************************************************************
** http://www.sitepoint.com/change-wordpress-33-toolbar/ *********************************** */
/* !어드민 툴바 커스트마이징 ******************************************************************** */
add_action('admin_bar_menu', 'change_toolbar', 999);
function change_toolbar($wp_toolbar) {
/* 로고 제거 */
$wp_toolbar->remove_node('wp-logo');
/* 미디어 업로드 제거 */
$wp_toolbar->remove_node('new-media');
/* change 'Howdy,' */