Here's how I define the CPT:

$args = array(
        'labels' => $labels,
        'public' => FALSE,
        'show_ui' => TRUE,
        'capability_type' => SNG_CAP_SUPPORT,
        'hierarchical' => FALSE,
        'supports' => array(
        'menu_icon' => SNG_PLUGIN_URL . '/images/admin-support.png',
        'rewrite' => FALSE,
        'has_archive' => FALSE );
    register_post_type( SNG_SUPPORT_POSTTYPE, $args );

Basically when a user creates a post of this post_type there's a success message that says "view this post" which leads to the front end of my site mysite.com/?sng-support=test-8. I want to remove this message and link but I'm not looking for a CSS fix. There MUST be a way to make this work? I tried playing with the args and I can't seem to figure out what I'm doing wrong...

Essentially I don't want the posts to be accessible from the URL or the front end unless I specifically query for them.

I appreciate any help! :)

  • can you prevent single.php from showing posts of that type?
    – GhostToast
    Jun 6, 2013 at 19:41
  • I guess I could redirect to the front page if the post type of the main query matches but I figured that there must be a way to do this within the definition. I guess I might be wrong.
    – Gazillion
    Jun 6, 2013 at 19:48
  • not sure there's anything that will remove that link, it'll just 404 if you set publicly_queryable to false.
    – Milo
    Jun 6, 2013 at 19:56

2 Answers 2


I think that at least part of what you want is to alter the submission update messages, probably in addition to @toscho's code.

function kill_message($messages) {
  global $post_type;
//   var_dump($messages); die;
  if ('your-cpt-slug' == $post_type) {
    // alter your message strings
  return $messages;
add_filter( 'post_updated_messages', 'kill_message' );

If you var_dump the $messages variable it is pretty obvious what the messages represent. Just rewrite them however you want.


This is a known bug: #17609 'View post' link shown even when post type can't be viewed on the front-end.

To fix it, filter get_sample_permalink_html and test the post type properties:

add_filter( 'get_sample_permalink_html', function( $html, $post_id )
    $post_type = get_post_type( $post_id );
    $object    = get_post_type_object( $post_type );

    if ( $object->public && $object->publicly_queryable )
        return $html;

    add_filter( 'get_shortlink', function( $shortlink, $id ) use ( $post_id )
        return $id == $post_id ? '' : $shortlink;
    }, 10, 2 );

    return '';

}, 10, 2 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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