2014-10-30 1 views
1

는 내가 목록에서 "제목"을 제거해야, 내가 manage_commercial_cpi_posts_columns, 에 새로운 열을 추가 관리 어떻게 정의 게시물 목록을 사용자 정의하는 많은 검색하지만, , 여전히 편집, 삭제 옵션이 있습니다. 어떻게해야합니까?워드 프레스 변화 사용자 정의 포스트 유형 제목

+0

목록 페이지가 지금 무엇입니까? 제목을 바꿀 수 있습니까? –

답변

2

CSS 또는 JS로 제목 링크를 숨길 수 있지만 여기에는 PHP 접근 방식이 있습니다.

다음
add_filter('manage_commercial_cpi_posts_columns', 'manage_commercial_cpi_posts_columns', 25, 1); 
function manage_commercial_cpi_posts_columns($cols) 
{ 
    // remove title column 
    unset($cols['title']); 

    // add custom column 
    $cols['ccpi_links'] = __('Edit', 'textdomain'); 

    // return columns 
    return $cols; 
} 

는 링크를 생성하는 WP_List_Table 클래스의 row_actions 방법을 사용 : 첫 번째 정의를 제목 열을 제거하고 추가 할 수 있습니다. 코드는 WP_Posts_List_Table 클래스에서 복사됩니다. 중요한 세부 사항은 을 row_actions 메서드의 두 번째 매개 변수로 추가하여 링크가 항상 표시되는지 확인하는 것입니다.

add_action('manage_commercial_cpi_posts_custom_column', 'manage_commercial_cpi_custom_column', 10, 2); 
function manage_commercial_cpi_custom_column($col, $post_id) 
{ 
    switch($col) : 

    case 'ccpi_links' : 

     // variables 
     $post    = get_post($post_id); 
     $title    = _draft_or_post_title(); 
     $post_type_object = get_post_type_object($post->post_type); 
     $can_edit_post  = current_user_can('edit_post', $post->ID); 

     // set up row actions 
     $actions = array(); 
     if ($can_edit_post && 'trash' != $post->post_status) { 
      $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>'; 
      $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick&nbsp;Edit') . '</a>'; 
     } 
     if (current_user_can('delete_post', $post->ID)) { 
      if ('trash' == $post->post_status) 
       $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>"; 
      elseif (EMPTY_TRASH_DAYS) 
       $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>"; 
      if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) 
       $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>"; 
     } 
     if ($post_type_object->public) { 
      if (in_array($post->post_status, array('pending', 'draft', 'future'))) { 
       if ($can_edit_post) { 
        $preview_link = set_url_scheme(get_permalink($post->ID)); 
        /** This filter is documented in wp-admin/includes/meta-boxes.php */ 
        $preview_link = apply_filters('preview_post_link', add_query_arg('preview', 'true', $preview_link), $post); 
        $actions['view'] = '<a href="' . esc_url($preview_link) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 
       } 
      } elseif ('trash' != $post->post_status) { 
       $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 
      } 
     } 

     // invoke row actions 
     $table = new WP_Posts_List_Table; 
     echo $table->row_actions($actions, true); 

     break; 

    endswitch; 
} 

결과

enter image description here

+0

감사합니다. 매우 도움이됩니다. – dvircn

관련 문제