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 have created a custom post type, but I want to remove the View link from actions, in the listing of the custom post.

I have tried this snippet

   add_filter( 'post_row_actions',array(&$this, 'remove_row_actions', 10, 1));
   public function remove_row_actions($action){
       unset($action['view']);
       return $action;
   }

But it throws

call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members in D:\wamp\www\wordpress\wp-includes\plugin.php on line 173

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You've got typo in your add_filter. Try this:

add_filter( 'post_row_actions',array(&$this, 'remove_row_actions'), 10, 1);

public function remove_row_actions($action){
    unset($action['view']);
    return $action;
}
share|improve this answer
    
doesnt work still, i renamed post_row_actions to page_row_actions also, still it doesnt get removed –  meWantToLearn Mar 14 '13 at 14:32
    
Must be something with your class code. Inserting this code into functions.php works great: add_filter( 'post_row_actions', 'remove_row_actions', 10, 1); function remove_row_actions($action){ unset($action['view']); return $action; } –  david.binda Mar 14 '13 at 14:43
add comment

The difference between class methods and functions is that you don't throw in an array() when calling the function and ommit the leading public/protected/private/static string in front of function. Also don't use the & when calling $this (which is the current class object), as it's PHP4 syntax for passing the class as reference. PHP5 doesn't need this. The third note is, that you use the array() in the way array( __CLASS__, 'method_name' ). The priority 10 and the number of arguments 1 as separate arguments and don't belong inside the array.

   add_filter( 'post_row_actions', 'wpse90843_remove_row_actions' );
   public function wpse90843_remove_row_actions( $action )
   {
       unset $action['view'];
       return $action;
   }

Last note: Don't just grab a snippet from somewhere if you don't understand what you're doing. Get someone who can read this for you. Stuff like this can seriously mess up your installation.

share|improve this answer
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.