Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

(Since my custom post type is a little long, I've for the sake of simplicity, copied over a dummy one)

What I am trying to do is, say I describe a few "similar" variables, i.e. price1, price2, price3, etc. would I be able to stack those values in a single column (as opposed to showing it over 3 columns), i.e. $price1<br />$price2<br />$price3 ? The reasons are purely aesthetic as the custom post type columns would get really crowded quickly otherwise.

Thank you! (like said, the part below isn't the actual code I'm using, but I thought it would be good if someone else would be searching the same thing)

add_filter("manage_edit-product_columns", "prod_edit_columns");
add_action("manage_posts_custom_column",  "prod_custom_columns");

function prod_edit_columns($columns){
  $columns = array(
   "cb" => "<input type=\"checkbox\" />",
   "title" => "Product Title",
   "description" => "Description",
   "price1" => "Price1",
   "catalog" => "Catalog",
  );

  return $columns;
}

function prod_custom_columns($column){
  global $post;
  switch ($column)
  {
   case "description":
    the_excerpt();
    break;
   case "price": // Now here I have to define the field, but how would I drag in other subsequent price fields?
    $custom = get_post_custom();
    echo $custom["price"][0];
    break;
   case "catalog":
    echo get_the_term_list($post->ID, 'catalog', '', ', ','');
    break;
  }
}
share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

yea you can do just that. you only need to change the output function which in this case is

function prod_custom_columns($column){
  global $post;
  switch ($column)
  {
   case "description":
    the_excerpt();
    break;
   case "price": // Now here I have to define the field, but how would I drag in other subsequent price fields?
    $custom = get_post_custom();
    echo $custom["price"][0];
    break;
   case "catalog":
    echo get_the_term_list($post->ID, 'catalog', '', ', ','');
    break;
  }
}

to display what you want for each column say your price change it to something like:

case "price": // Now here I have to define the field, but how would I drag in other subsequent price fields?
    $custom = get_post_custom();
    echo $custom["price"][0];
    echo 'br />';
    echo $custom["another_FIELD"][0];
    echo 'br />';
    echo $custom["yet_another_FIELD"][0];
    break;

hope this helps

share|improve this answer
    
Duh, it's actually exactly the code I had in there, but didn't expect it to function for some reason. Thanks! –  Noel Tock Jan 31 '11 at 20:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.