Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

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

share|improve this answer
    
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 Oct 20 '11 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. –  Rutwick Gangurde Oct 21 '11 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 Oct 21 '11 at 20:57
    
You're welcome... keep checking this thread, I'll look around for someone to write the regex and update my answer. –  Rutwick Gangurde Oct 22 '11 at 6:11
    
Hi... Please check the code now. –  Rutwick Gangurde Oct 22 '11 at 15:02
show 15 more comments

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.

share|improve this answer
    
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 Oct 20 '11 at 18:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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