1

Is there any way to define a post.php for a Custom Content Type?

I am trying to remove the Permalink, the Slug and the Preview Changes Button from the edit/creation page of an item in my custom content type.

1

To remove Preview Button

function posttype_admin_css() {
    global $post_type;
    $post_types = array(
                        /* set post types */
                        'post_type_name'
                  );
    if(in_array($post_type, $post_types))
    echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
}
add_action( 'admin_head-post-new.php', 'posttype_admin_css' );
add_action( 'admin_head-post.php', 'posttype_admin_css' );

To remove slug

function vipx_remove_cpt_slug( $post_link, $post, $leavename ) {

    if ( 'post_type_name' != $post->post_type || 'publish' != $post->post_status ) {
        return $post_link;
    }

    $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );

    return $post_link;
}
add_filter( 'post_type_link', 'vipx_remove_cpt_slug', 10, 3 );

Source: http://vip.wordpress.com/documentation/remove-the-slug-from-your-custom-post-type-permalinks/ http://wpsnipp.com/index.php/functions-php/hide-post-view-and-post-preview-admin-buttons/


If I understood your question correctly, here is your answer.

single-typename.php
archive-typename.php

For example, you've a custom post type defined as book. single-book.php should be you're looking for.

  • The question seems to be about admin editor rather than front end template. – Rarst Mar 16 '14 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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