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.

I'm working on a plugin, which converts a site into a feedback sort of portal. I made a new object page, 'Feedbacks', which displays all the feedbacks is a tabular format, and I'm using register_column_headers($array_of_column_headers) to make my table. I wanted to know if it is possible to add my own page row actions to this table, i mean under every feedback in the list, actions like 'approve', 'delete', 'blacklist' etc.

I read the code and a couple of tickets, and found out its done this way: for posts, its post_row_actions, for comments its comment_row_actions, for media its media_row_actions and so on. Is there a filter that allows me to do, my-page-slug_row_actions?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

When using custom post type you use the post_row_actions filter hook and check the post type to modify it only:

add_filter('post_row_actions','my_action_row', 10, 2);

function my_action_row($actions, $post){
    //check for your post type
    if ($post->post_type =="feedbacks"){
        /*do you stuff here
        you can unset to remove actions
        and to add actions ex:
        $actions['in_google'] = '<a href="http://www.google.com/?q='.get_permalink($post->ID).'">check if indexed</a>';
        */
    }
    return $actions;
}

Quick update:

thanks to somatic if you custom post type is "hierarchical" then you action hook is: page_row_actions.

share|improve this answer
    
Does $post have scope? hint hint ;) –  t31os Apr 18 '11 at 11:38
    
@t310s Fixed @Bainternet hope you don't mind ,) –  kaiser Apr 18 '11 at 12:37
2  
@kaiser: And improved your fix! –  Jan Fabry Apr 18 '11 at 13:31
    
Hi, I already used 'post_row_actions' for adding a link in the the custom posts rows. But I want to do it for my menu page, which is added using 'add_object_page' hook (which is similar to 'add_menu_page'). add_object_page("Feedbacks", "Feedbacks", 10, "feedbacks-menu", "FeedbackMenuFunction"); add_submenu_page("feedbacks-menu", "Pending Feedbacks", "Pending", 10, "pending-feedbacks-menu", "PendingFeedbackMenuFunction") I was wondering if I could do, 'feedbacks-menu_row_actions(...)' (just like its done for other pages like 'Posts', 'Comments' etc using the page slug with row actions). –  Rutwick Gangurde Apr 18 '11 at 15:31
2  
for those of you banging your head on your desk wondering why this code seems to do nothing with your custom post type, note: if your CPT is "hierarchical", then your filter hook is "page_row_actions" and NOT "post_row_actions" [rubs head] –  somatic May 5 '11 at 5:22
show 4 more comments

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.