Removing Edit Permalink/View “Custom Post Type” areas

There is a filter get_sample_permalink_html that returns this area as a string. Here’s how you can use it:

<?php
    add_filter('get_sample_permalink_html', 'perm', '',4);

    function perm($return, $id, $new_title, $new_slug){
        global $post;
        if($post->post_type == 'testimonials')
        {
            $ret2 = preg_replace('/<span id="edit-slug-buttons">.*<\/span>|<span id=\'view-post-btn\'>.*<\/span>/i', '', $return);
        }

        return $ret2;
    }
?>

Updated the code. Please check this.

Updated Changed the double quotes to single quote on view-post-btn. Tested up till 3.2

Leave a Comment