Removing Edit Permalink/View “Custom Post Type” areas

Trying to replicate some functionality I’ve seen on a few other themes before, but would like to know/understand for my own uses.

I’ve created a custom post type, called “testimonials”. I believe I’ve knocked out a pretty good chunk of the setup, using Justin Tadlock’s awesome post on Custom Post Types. I’ve also seen his post on removing meta boxes, which is great. The thing I’m after is, when you usually type in a title on a post/page and click off of it, you’ll get an “edit permalink” area. Normally, this is actually a useful thing, but in my case, for “testimonials” or “slideshow slides” this may actually confuse the user. Furthermore, once you save a “testimonial” or “slide”, you may not want there to be an actual “single view”. I’m not sure how it is normally done (poked around inside WooThemes — but I’m still lost). I could do this with CSS, but looking at the actual source code of the page for Woothemes for example… it’s just gone (which is what I prefer). Any help would be greatly appreciated. Thanks!

Related posts

Leave a Reply

3 comments

  1. 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