我有个神秘的问题。我已经成功创建了一个自定义的帖子类型,以及相关的类别。但是,当我列出帖子时,“快速编辑”部分不会显示标题、日期或任何信息。它是空白的,我不知道为什么。有人能看到问题吗?
//////////////////////// setup admin pages
add_action( \'init\', \'mmd_client_tracking_form\', 0 ); // Add the menu
function mmd_client_tracking_form()
{
$labels = array(
\'name\' => _x( \'Review Client Workouts\', \'mmd_client_list\' ),
\'singular_name\' => _x( \'Manage Clients\', \'mmd_client_list\' ),
\'add_new\' => _x( \'New Client\', \'mmd_client_list\' ),
\'add_new_item\' => __( \'Add New Client\' ),
\'edit_item\' => __( \'Edit Client\' ),
\'new_item\' => __( \'New Client\' ),
\'all_items\' => __( \'Workout Clients\' ),
\'view_item\' => __( \'View Client\' ),
\'search_items\' => __( \'Search Clients\' ),
\'not_found\' => __( \'No Clients found\' ),
\'not_found_in_trash\' => __( \'No Clients found in the Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Biorider Tracking\'
);
$args = array(
\'register_meta_box_cb\' => \'mmdtrack_meta_box\', // Register a meta box
\'labels\' => $labels,
\'description\' => \'This post type holds all posts for your directory items.\',
\'public\' => true,
\'menu_position\' => 10,
\'show_ui\' => true,
\'supports\' => array( \'title\' ),
\'has_archive\' => true,
\'menu_icon\' => \'dashicons-media-spreadsheet\',
);
register_post_type( \'mmdtrack\', $args );
}
//-----------------------------------------------------------------
// CUSTOM CATAGORY
//-----------------------------------------------------------------
add_action( \'init\', \'mmd_track_taxonomies\', 0 ); // Add the standard submenu
function mmd_track_taxonomies() {
$labels = array(
\'name\' => _x( \'Biorider Categories\', \'Biorider Categories\' ),
\'singular_name\' => _x( \'Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Clients Categories\' ),
\'all_items\' => __( \'All Clients Categories\' ),
\'parent_item\' => __( \'Parent Clients Categories\' ),
\'parent_item_colon\' => __( \'Parent Clients Category:\' ),
\'edit_item\' => __( \'Edit Clients Category\' ),
\'update_item\' => __( \'Update Clients Category\' ),
\'add_new_item\' => __( \'Add New Clients Category\' ),
\'new_item_name\' => __( \'New Clients Category Name\' ),
\'menu_name\' => __( \'Clients Categories\')
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'mmdtrack_cat\' )
);
register_taxonomy( \'mmdtrack_cat\', \'mmdtrack\', $args );
}
add_action( \'init\', \'mmd_tracking_menu\', 0 ); // Add the standard submenu
function mmd_tracking_menu()
{
add_submenu_page(\'edit.php?post_type=mmdtrack\', // Parent Slug from add_menu_page
\'Biorider Settings\', // Title of page
\'Settings\', // Menu title
\'manage_options\', // Minimum capability to view the menu.
\'mmd_Tracking_Settings_slug\', // Unqiue Slug Name
\'mmd_trackingAdminPage\' ); // A callback function used to display page content.
}
//-----------------------------------------------------------------
// ENTRIES OF MEMBER LISTINGS - MANUAL
//-----------------------------------------------------------------
function mmdtrack_meta_box(WP_Post $post)
{
$prefix = \'mmdtrack\'; // Custom Post Name
add_meta_box($prefix, \'Set Tracking\', mmdtrack_client_tracking_form);
}
function mmdtrack_client_tracking_form($PostId)
{
... displaying code for metabox
}
////////////////////////////////////////////////////////////////////////
// THIS HOOKS IN TO WORDPRESS CUSTOM POST AND CHANGES THE
// MANAGE LIST FORM
//////////////////////////////////////////////////////////////////////
add_filter(\'manage_mmdtrack_posts_columns\', \'mmd_member_track_columns_head\');
function mmd_member_track_columns_head($defaults) {
$new_columns[\'cb\'] = \'<input type="checkbox" />\';
$new_columns[\'mmd_member_name\'] = \'Name\';
$new_columns[\'mmd_member_tracking_workout_count\'] = \'Number of Workouts\';
$new_columns[\'mmd_member_memberships\'] = \'Active Membershps\';
$new_columns[\'mmd_member_category\'] = \'Categories\';
return $new_columns;
}
add_action(\'manage_mmdtrack_posts_custom_column\', \'mmd_track_columns_content\', 10, 2);
function mmd_track_columns_content($column_name, $post_ID)
{
switch($column_name)
{
case \'mmd_member_name\':
$Name = get_the_title( $post_ID );
echo $Name;
break;
case \'mmd_member_tracking_workout_count\':
$user_ID = mmd_track_FindUser($post_ID);
echo mmd_track_GetWorkoutCnt($user_ID);
break;
case \'mmd_member_memberships\':
$user_ID = mmd_track_FindUser($post_ID);
if($user_ID==0)
echo "None";
break;
case \'mmd_member_category\':
$terms = get_the_terms( $post_ID, \'mmdtrack_cat\' );
/* If terms were found. */
if ( !empty( $terms ) )
{
$out = array();
/* Loop through each term, linking to the \'edit posts\' page for the specific term. */
foreach ( $terms as $term )
{
$out[] = sprintf( \'<a href="%s">%s</a>\',
esc_url( add_query_arg( array( \'post_type\' => \'mmdtrack\', \'mmdtrack_cat\' => $term->slug ), \'edit.php\' ) ),
esc_html( sanitize_term_field( \'name\', $term->name, $term->term_id, \'mmdtrack_cat\', \'display\' ) )
);
}
/* Join the terms, separating them with a comma. */
echo join( \', \', $out );
}
break;
}
}
function mmd_track_emptytrash($post_ID)
{
if(get_post_status( $post_id ) === \'trash\')
ClearMemberWorkouts($post_ID);
return 0;
}
add_action( \'before_delete_post\', \'mmd_track_emptytrash\');
////////////////////////////////////////////////////////////
// If a list is trashed, make sure all the list records are
// removed from the table.
////////////////////////////////////////////////////////////
function mmd_track_place_in_trash($post_ID)
{
}
add_action(\'wp_trash_post\', \'mmd_track_place_in_trash\');
SO网友:Debbie Kurth
多亏了Jg314,答案很简单。我拿走了默认标题,一旦恢复,一切都恢复了。
错误的方式。删除此$new_columns[\'mmd_member_name\']
如下所示
function mmd_member_track_columns_head($defaults) {
$new_columns[\'cb\'] = \'<input type="checkbox" />\';
$new_columns[\'mmd_member_name\'] = \'Name\';
$new_columns[\'mmd_member_tracking_workout_count\'] = \'Number of Workouts\';
$new_columns[\'mmd_member_memberships\'] = \'Active Membershps\';
$new_columns[\'mmd_member_category\'] = \'Categories\';
return $new_columns;
}
add_action(\'manage_mmdtrack_posts_custom_column\', \'mmd_track_columns_content\', 10, 2);
function mmd_track_columns_content($column_name, $post_ID)
{
然后删除关联的密钥
case \'mmd_member_name\':
switch($column_name)
{
case \'mmd_member_name\':
$Name = get_the_title( $post_ID );
echo $Name;
break;
case \'mmd_member_tracking_workout_count\':
$user_ID = mmd_track_FindUser($post_ID);
echo mmd_track_GetWorkoutCnt($user_ID);
break;
case \'mmd_member_memberships\':
$user_ID = mmd_track_FindUser($post_ID);
if($user_ID==0)
echo "None";
break;
case \'mmd_member_category\':
$terms = get_the_terms( $post_ID, \'mmdtrack_cat\' );
/* If terms were found. */
if ( !empty( $terms ) )
{
$out = array();
/* Loop through each term, linking to the \'edit posts\' page for the specific term. */
foreach ( $terms as $term )
{
$out[] = sprintf( \'<a href="%s">%s</a>\',
esc_url( add_query_arg( array( \'post_type\' => \'mmdtrack\', \'mmdtrack_cat\' => $term->slug ), \'edit.php\' ) ),
esc_html( sanitize_term_field( \'name\', $term->name, $term->term_id, \'mmdtrack_cat\', \'display\' ) )
);
}
/* Join the terms, separating them with a comma. */
echo join( \', \', $out );
}
break;
}
}
是什么修复了它。添加回
$new_columns[\'title\'] = __(\'Title\');
add_filter(\'manage_mmdclienttrack_posts_columns\', \'mmd_member_track_columns_head\');
function mmd_member_track_columns_head($defaults) {
$new_columns[\'cb\'] = \'<input type="checkbox" />\';
$new_columns[\'title\'] = __(\'Title\');
$new_columns[\'mmd_member_tracking_workout_count\'] = \'Number of Workouts\';
$new_columns[\'mmd_member_memberships\'] = \'Active Membershps\';
$new_columns[\'mmd_member_category\'] = \'Categories\';
return $new_columns;
}
```