0

Currently i m using this shorocdes

add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );
function remove_row_actions( $actions )
{
if( get_post_type() === 'post' ) 
    unset( $actions['edit'] );
return $actions;
}

for removing edit link from published post but this code is applied on all post states and i want to apply this filter only for published and pending post. can any one help me to apply this filter only for published and pending post instead of All posts

enter image description here

1 Answer 1

0

Try this, where I changed the function to accept the second parameter which is the current post in the list table:

add_filter( 'post_row_actions', 'remove_row_actions', 10, 2 );
function remove_row_actions( $actions, $post )
{
    if ( $post && 'post' === $post->post_type &&
        in_array( $post->post_status, array( 'publish', 'pending' ) )
    ) {
        unset( $actions['edit'] );
    }

    return $actions;
}
1
  • 1
    thank you very much @Sally CJ. Your Code is correct and working smoothly. Sep 15, 2021 at 17:53

Your Answer

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

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