Skip to main content
deleted 281 characters in body
Source Link
hawbsl
  • 500
  • 1
  • 11
  • 30

Our admin dashboard list of our custom post type shows by default two columns - title and categories.

We want to improve the list, and to add the foobar custom field. So we do that as follows:

add_action('manage_myproduct_posts_columns', 'manage_myproduct_posts_columns');
function manage_heatherproduct_posts_columns($post_columns) {
  $_REQUEST['mode'] = 'excerpt';
    $post_columns = array(
        'cb' => $post_columns['cb'],
        'title' =>  'Product',        
        'categories' => 'Categories',
        'myproduct_foobar' => 'foobar',
        );
    return $post_columns;
}

That shows the title and the foobar field fine (code which pulls in the foobar data not shown). But now, the categories column is semi-broken. One of the categories is shown, correctly, for those products which fit into that category. But none of the other categories ever show up. Instead we just see a dash.

What are we doing wrong?

NB. I've not included the code where we pull in the data for the custom column foobar as the category problem seems to occur even if we comment that out.

Edit
After a bit of investigation I'm beginning to think the category being listed (the "one" category) isn't really one of my categories but was something which I created inadvertently when importing a bunch of products using the CSV Importer plugin. Still looking at this.

Our admin dashboard list of our custom post type shows by default two columns - title and categories.

We want to improve the list, and to add the foobar custom field. So we do that as follows:

add_action('manage_myproduct_posts_columns', 'manage_myproduct_posts_columns');
function manage_heatherproduct_posts_columns($post_columns) {
  $_REQUEST['mode'] = 'excerpt';
    $post_columns = array(
        'cb' => $post_columns['cb'],
        'title' =>  'Product',        
        'categories' => 'Categories',
        'myproduct_foobar' => 'foobar',
        );
    return $post_columns;
}

That shows the title and the foobar field fine (code which pulls in the foobar data not shown). But now, the categories column is semi-broken. One of the categories is shown, correctly, for those products which fit into that category. But none of the other categories ever show up. Instead we just see a dash.

What are we doing wrong?

NB. I've not included the code where we pull in the data for the custom column foobar as the category problem seems to occur even if we comment that out.

Edit
After a bit of investigation I'm beginning to think the category being listed (the "one" category) isn't really one of my categories but was something which I created inadvertently when importing a bunch of products using the CSV Importer plugin. Still looking at this.

Our admin dashboard list of our custom post type shows by default two columns - title and categories.

We want to improve the list, and to add the foobar custom field. So we do that as follows:

add_action('manage_myproduct_posts_columns', 'manage_myproduct_posts_columns');
function manage_heatherproduct_posts_columns($post_columns) {
  $_REQUEST['mode'] = 'excerpt';
    $post_columns = array(
        'cb' => $post_columns['cb'],
        'title' =>  'Product',        
        'categories' => 'Categories',
        'myproduct_foobar' => 'foobar',
        );
    return $post_columns;
}

That shows the title and the foobar field fine (code which pulls in the foobar data not shown). But now, the categories column is semi-broken. One of the categories is shown, correctly, for those products which fit into that category. But none of the other categories ever show up. Instead we just see a dash.

What are we doing wrong?

NB. I've not included the code where we pull in the data for the custom column foobar as the category problem seems to occur even if we comment that out.

added 289 characters in body
Source Link
hawbsl
  • 500
  • 1
  • 11
  • 30

Our admin dashboard list of our custom post type shows by default two columns - title and categories.

We want to improve the list, and to add the foobar custom field. So we do that as follows:

add_action('manage_myproduct_posts_columns', 'manage_myproduct_posts_columns');
function manage_heatherproduct_posts_columns($post_columns) {
  $_REQUEST['mode'] = 'excerpt';
    $post_columns = array(
        'cb' => $post_columns['cb'],
        'title' =>  'Product',        
        'categories' => 'Categories',
        'myproduct_foobar' => 'foobar',
        );
    return $post_columns;
}

That shows the title and the foobar field fine (code which pulls in the foobar data not shown). But now, the categories column is semi-broken. One of the categories is shown, correctly, for those products which fit into that category. But none of the other categories ever show up. Instead we just see a dash.

What are we doing wrong?

NB. I've not included the code where we pull in the data for the custom column foobar as the category problem seems to occur even if we comment that out.

Edit
After a bit of investigation I'm beginning to think the category being listed (the "one" category) isn't really one of my categories but was something which I created inadvertently when importing a bunch of products using the CSV Importer plugin. Still looking at this.

Our admin dashboard list of our custom post type shows by default two columns - title and categories.

We want to improve the list, and to add the foobar custom field. So we do that as follows:

add_action('manage_myproduct_posts_columns', 'manage_myproduct_posts_columns');
function manage_heatherproduct_posts_columns($post_columns) {
  $_REQUEST['mode'] = 'excerpt';
    $post_columns = array(
        'cb' => $post_columns['cb'],
        'title' =>  'Product',        
        'categories' => 'Categories',
        'myproduct_foobar' => 'foobar',
        );
    return $post_columns;
}

That shows the title and the foobar field fine (code which pulls in the foobar data not shown). But now, the categories column is semi-broken. One of the categories is shown, correctly, for those products which fit into that category. But none of the other categories ever show up. Instead we just see a dash.

What are we doing wrong?

NB. I've not included the code where we pull in the data for the custom column foobar as the category problem seems to occur even if we comment that out.

Our admin dashboard list of our custom post type shows by default two columns - title and categories.

We want to improve the list, and to add the foobar custom field. So we do that as follows:

add_action('manage_myproduct_posts_columns', 'manage_myproduct_posts_columns');
function manage_heatherproduct_posts_columns($post_columns) {
  $_REQUEST['mode'] = 'excerpt';
    $post_columns = array(
        'cb' => $post_columns['cb'],
        'title' =>  'Product',        
        'categories' => 'Categories',
        'myproduct_foobar' => 'foobar',
        );
    return $post_columns;
}

That shows the title and the foobar field fine (code which pulls in the foobar data not shown). But now, the categories column is semi-broken. One of the categories is shown, correctly, for those products which fit into that category. But none of the other categories ever show up. Instead we just see a dash.

What are we doing wrong?

NB. I've not included the code where we pull in the data for the custom column foobar as the category problem seems to occur even if we comment that out.

Edit
After a bit of investigation I'm beginning to think the category being listed (the "one" category) isn't really one of my categories but was something which I created inadvertently when importing a bunch of products using the CSV Importer plugin. Still looking at this.

Source Link
hawbsl
  • 500
  • 1
  • 11
  • 30

Customising the admin columns for a custom post type, but now most of the built in categories don't display?

Our admin dashboard list of our custom post type shows by default two columns - title and categories.

We want to improve the list, and to add the foobar custom field. So we do that as follows:

add_action('manage_myproduct_posts_columns', 'manage_myproduct_posts_columns');
function manage_heatherproduct_posts_columns($post_columns) {
  $_REQUEST['mode'] = 'excerpt';
    $post_columns = array(
        'cb' => $post_columns['cb'],
        'title' =>  'Product',        
        'categories' => 'Categories',
        'myproduct_foobar' => 'foobar',
        );
    return $post_columns;
}

That shows the title and the foobar field fine (code which pulls in the foobar data not shown). But now, the categories column is semi-broken. One of the categories is shown, correctly, for those products which fit into that category. But none of the other categories ever show up. Instead we just see a dash.

What are we doing wrong?

NB. I've not included the code where we pull in the data for the custom column foobar as the category problem seems to occur even if we comment that out.