WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Change edit page columns (2 posts)

  1. coopersita
    Member
    Posted 3 years ago #

    Hi,

    I'm trying to change the information shown in the listing of posts for a custom post type I have:

    add_action("manage_posts_custom_column", "tips_custom_columns");
    add_filter("manage_edit-tips_columns", "tips_edit_columns");
    
    function tips_edit_columns($columns){
      $columns = array(
        "cb" => "<input type=\"checkbox\" />",
        "title" => "Title",
        "cat" => "Topic Category",
        "featured" => "Featured",
        "comments" => '<div class="vers"><img alt="Comments" src="/wp-admin/images/comment-grey-bubble.png" /></div>',
        "date" => "Date",
      );
    
      return $columns;
    }
    
    function tips_custom_columns($column){
      global $post;
    
      switch ($column) {
        case "featured":
          $custom = get_post_custom();
          echo $custom["featured"][0];
          break;
        case "cat":
          echo get_the_term_list($post->ID, 'Topic Categories', '', ', ','');
          break;
      }
    }

    I do get the columns I'm asking for ("tips_edit_columns"), but my custom columns are empty. It's like it's not even going over "tips_custom_columns".

    I took the code from here (step 4): http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/ but it's not working.

    I used this code on another site, and it worked fine, but now I just don't see where my error is.

    Thanks

  2. coopersita
    Member
    Posted 3 years ago #

    Eureka!

    Since it's a hierarchical custom post type, I needed to change "manage_posts_custom_column" to "manage_pages_custom_column".

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.