1

I have created a custom post type called "form-enquiry". I'm trying to change the actions that appear when the admin hovers over the posts on the edit.php page. See screenshot below

enter image description here

I managed to find the array which was holding the settings and add my own custom one called "reply" into the array. However, I can't work out how to get post id for the link.

See below for the code I have so far. Is it possible to get the id for the post and insert it into the link to get something like post.php?post=95&action=reply when the user clicks on the custom button.

  function remove_quick_edit($actions)
  {
    if($_GET['post_type'] == 'form-enquiry')
    {
      unset($actions['inline hide-if-no-js']);
    }

    $actions['reply'] = '<a href="#">Reply</a>';
    //return $actions;

    echo '<pre>'; print_r($actions); echo '</pre>';
  }
  add_filter('post_row_actions', 'remove_quick_edit', 10, 1);

1 Answer 1

1

If you look here https://developer.wordpress.org/reference/hooks/post_row_actions/, the second argument for the post_row_actions filter is a post object, so you should be able to do :

 function remove_quick_edit($actions, $post)
  {
    $post_id = $post->ID;
    $post_type = $post->post_type;
    if($_GET['post_type'] == 'form-enquiry')
    {
      unset($actions['inline hide-if-no-js']);
    }

    $actions['reply'] = '<a href="#">Reply</a>';
    //return $actions;

    echo '<pre>'; print_r($actions); echo '</pre>';
  }
  add_filter('post_row_actions', 'remove_quick_edit', 10, 2);
2
  • Thanks! Do you know if there is any way to add a custom action to these? I see when I click on the Edit button I get this link ?post=95&action=edit Is it possible to create a link with &action=reply? I tried manually putting this in but WordPress throws this error "Are you sure you want to do this?" Commented Dec 5, 2016 at 21:19
  • 1
    You may need a nonce, this answer here provides some information on that wordpress.stackexchange.com/questions/99211/… Commented Dec 5, 2016 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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