投稿一覧への添付ファイルリンク追加と削除


 /**
  *  投稿一覧に項目を削除する
  *
  *
  *
  *
  */
 
 //add_filter('manage_posts_columns', 'remove_my_columns');
 function remove_my_columns($defaults) {
  unset($defaults['attachments']);
  unset($defaults['author']);
  return $defaults;
 }
 
 /**
  *  添付ファイルを投稿一覧ページに追加 表示する
  *
  *
  *
  *
  */
 
 add_action('manage_posts_custom_column', 'scompt_custom_column', 10, 2);
 
 
 function scompt_custom_column($column_name, $post_id) {
  global $wpdb;
  if( $column_name== 'attachments' ) {
  $query= "SELECT post_title, ID FROM $wpdb->posts ".
  "WHERE post_type='attachment' ".
  "AND post_parent='$post_id'";
  $attachments= $wpdb->get_results($query);
  if( $attachments ) {
 $my_func= create_function('$att',
  'return "<a href=\"".get_permalink($att->ID)."\">".
  $att->post_title.
  "</a>";');
 $text= array_map($my_func, $attachments);
 echo implode(', ',$text);
  } else {
 echo '<i>'.__('None').'</i>';
  }
  }
 }

[emulsion_relate_posts]