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!

3 Answers 3


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

    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

  • Wow! That was quick :) I really appreciate the sample code. I implemented it and see it outputting what is normally returned "off-click" in the permalink area -- do you have an example where I would actually remove this area just for testimonials, like you had with the "if" statement? Really starting to understand the power of filters, but am a little fuzzy on the PHP for this area. Thanks!
    – Zach
    Commented Oct 20, 2011 at 18:47
  • Sorry, I could've completed the entire code, but you need a regular expression to remove the <span> that surrounds those 2 buttons from the $return variable, and I'm not good at regex! In place of testimonials from the if part in the code, you can put any post type to check. Commented Oct 21, 2011 at 17:36
  • Thanks for the response - I'm unfortunately a little fuzzy on that subject as well - I may have to give the CSS way a try for now - unless someone else chimes in. Thank you again very much!
    – Zach
    Commented Oct 21, 2011 at 20:57
  • You're welcome... keep checking this thread, I'll look around for someone to write the regex and update my answer. Commented Oct 22, 2011 at 6:11
  • Hi... Please check the code now. Commented Oct 22, 2011 at 15:02

You could also use CSS to hide it, based on your client's role. If you're interested, I can give you a code sample.

  • Really appreciate you taking a look. I think I had done that previously, here is how I went about doing it: add_action('admin_head', 'testimonials_admin_css'); function testimonials_admin_css() { $tempDir = get_bloginfo('stylesheet_directory'); global $post_type; if (($_GET['post_type'] == 'testimonials')) : echo "<link type='text/css' rel='stylesheet' href='" . $tempDir . "/inc/css/admin_testimonials.css' />"; endif; } I think the PHP way may be cleaner though.
    – Zach
    Commented Oct 20, 2011 at 18:58
  • @Johnathan Wold: Would be more useful to post the code sample as it might interest other people at StackExchange as well... ;-)
    – Philipp
    Commented Nov 26, 2014 at 10:28

If using css:

#edit-slug-box {
display: none;
  • 1
    The OP explicitly said that he was looking for a solution that didn't involve CSS.
    – shea
    Commented May 12, 2015 at 1:49

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.