0
add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );

function remove_row_actions( $actions )
{
    if( get_post_type() == 'my_cpt' )
        unset( $actions['view'] );
    return $actions;
}

This code removes the view link from post list, but I want to remove the link from post edit page also. Can anyone help ?

1

2 Answers 2

0

(1) The Edit Permalink HTML including the View-Post button is passed through the get_sample_permalink_html filter. You will likely have to preg_replace() the view post button out of it:

function my_get_sample_permalink_html($a){
    return preg_replace("/<span id='view-post-btn'>(.*)<\/span>/",'',$a);
}
add_filter('get_sample_permalink_html','my_get_sample_permalink_html');

(2) The message after a post has been updated can be altered by filtering post_updated_messages. Like this:

function my_post_updated_messages( $messages ) {
    $messages['post'][1] = __('Post updated');
    return $messages;
}
add_filter('post_updated_messages','my_post_updated_messages');
1
0

Make sure post args public and publicly_queryable are set to false. or use

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

function remove_row_actions( $actions, $post )
{
    if ($post->post_type == "post_type") {
        unset( $actions['view'] );
    }
    return $actions;
}

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.