WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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! :)

share|improve this question
can you prevent single.php from showing posts of that type? – GhostToast Jun 6 '13 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 '13 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 '13 at 19:56
up vote 1 down vote accepted

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.

share|improve this answer
Thanks this will help take out the link but that specific filter only works for the update message. I can't find the post_added_messages (or something of the sort) in the codex codex.wordpress.org/Plugin_API/Filter_Reference ... Any idea what the filter name is? – Gazillion Jun 6 '13 at 20:54
I'm a dink, it's all in the same filter. wordpress.stackexchange.com/questions/17885/… – Gazillion Jun 6 '13 at 20:57

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 );
share|improve this answer

Your Answer


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.