No Edit / Delete Links for Custom Post Type?

I’ve created a custom post type for “testimonials” as well as rearranged the edit post display with custom columns for that post type… Everything works as expected EXCEPT for the fact that when I hover over one of these custom posts, the list of “action links” that normally appears beneath it enabling you to edit/delete that post aren’t there…

Here’s a screenshot of what I mean:
enter image description here

Here’s all the related code:

function wpg_edit_testimonials_columns($columns) {
  $columns = array(
    'cb' => '<input type="checkbox" />',
    'testimonial_author' => __('Author', 'quotable'),
    'testimonial_text' => __('Testimonial', 'quotable'),
    'attribution_link' => __('Attribution Link', 'quotable'),
    'date' => __('Date Added', 'quotable')
  );
  return $columns;
}

function wpg_manage_testimonials_columns($column, $post_id) {
  global $post;
  $custom = get_post_custom($post->ID);
  $testimonial_author_name = $custom['testimonial_author_name'][0];
  $testimonial_author_link = $custom['testimonial_author_link'][0];

  switch($column) {

    case 'testimonial_author':
      echo $testimonial_author_name;
    break;

    case 'testimonial_text':
      echo $post->post_content;
    break;

    case 'attribution_link':
      echo $testimonial_author_link;
    break;

    default :
      break;
  }
}
add_filter('manage_edit-testimonials_columns', 'wpg_edit_testimonials_columns');
add_action('manage_testimonials_posts_custom_column', 'wpg_manage_testimonials_columns', 10, 2);

My only guess is that maybe it has something to do with the fact that the “title” column isn’t being used? I didn’t see any need in using the title column since the post type doesn’t even support the use of “titles”, as it’s just a testimonial.

EDIT:

Ok, I’ve confirmed that it is, in fact, due to the fact that the title column isn’t being used… I added “title” to the list of columns in the array and the links appeared… However, since titles aren’t supported in this post type, the title is being listed as “Auto Draft” for all of the testimonials.

EDIT AGAIN:

Taking the advice of @helenhousandi, I’ve rolled my own set of links… but now I’m running into an entirely new problem. The delete/trash link uses a nonce, which I’ve added… but I’m apparently missing a step somewhere, because it’s not actually completing the action when clicked.

Instead I’m getting a WordPress failure notice:
enter image description here

Here’s the edited portion of my code:

$wpg_row_actions="<div class="row-actions"><span class="edit"><a title="".__('Edit this item', 'quotable').'" href="'.get_admin_url().'post.php?post=".$post->ID."&amp;action=edit">Edit</a> | </span>';
$wpg_row_actions .= '<span class="inline hide-if-no-js"><a title="'.__('Edit this item inline', 'quotable').'" class="editinline" href="#">Quick&nbsp;Edit</a> | </span>';
$wpg_row_actions .= '<span class="trash"><a href="'.wp_nonce_url(get_admin_url().'post.php?post=".$post->ID."&amp;action=trash', 'delete-post_'.$post->ID).'" title="'.__('Move this item to the Trash', 'quotable').'" class="submitdelete">Trash</a></span>';


switch($column) {
  case 'testimonial_author':
    echo $testimonial_author_name.$wpg_row_actions;
break;

3 Answers
3

Correct, without the title column, the row actions don’t have a place to show. I haven’t tried doing this before, but take a look at the row_actions() method in the WP_List_Table class. You may not be able to call it directly, but it should show you how those links are built so you can roll them yourself if you need to.

Leave a Comment