WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

Is it possible to edit the "Post updated. View post" link and remove the "View post" entirely? Also change the "Post" to the name of a cpt?

Thanks guys!

Update:

Here is the code I used and it worked like a charm. I hope this helps others!

In my example I use "Contact" as my cpt:

enter image description here

add_filter('post_updated_messages', 'contact_updated_messages');
function contact_updated_messages( $messages ) {

$messages['contact'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __('Contact updated. <a href="%s">View Contact</a>'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
4 => __('Contact updated.'),
/* translators: %s: date and time of the revision */
5 => isset($_GET['revision']) ? sprintf( __('Contact restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __('Contact published. <a href="%s">View Contact</a>'), esc_url( get_permalink($post_ID) ) ),
7 => __('Contact saved.'),
8 => sprintf( __('Contact submitted. <a target="_blank" href="%s">Preview Contact</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Contact scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Contact</a>'),
  // translators: Publish box date format, see http://php.net/date
  date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('Contact draft updated. <a target="_blank" href="%s">Preview Contact</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);

return $messages;
}

share|improve this question
    
Make it open in a new tab by following my directions here: codebucket.io/code/danielhickman/… – Daniel Hickman Jan 3 '15 at 3:15

You can filter the update messages: add_filter('post_updated_messages', 'your_message_function');

look in /wp-admin/edit-form-advanced.php to see the where the default messages are set.

share|improve this answer
    
Thanks Milo! Using your advice I have found what I wanted to do. I will edit my original post with the answer. – Marco Apr 22 '11 at 3:07
    
Thanks here too! Made them all open in a new tab by adding 'target="_blank"' to each <a> in the messages. Saved me a lot of time. – Daniel Hickman Jan 2 '15 at 10:41

To make this work for all CPTs, I found a gist that abstracts it into a simple function to drop in functions.php

https://gist.github.com/benklocek/2b510994c3ecbe508af6

/**
* Replaces "Post" in the update messages for custom post types on the "Edit"post screen.
* For example, for a "Product" custom post type, "Post updated. View Post." becomes "Product updated. View Product".
*
* @param array $messages The default WordPress messages.
*/

function pico_custom_update_messages( $messages ) {
global $post, $post_ID;

$post_types = get_post_types( array( 'show_ui' => true, '_builtin' => false ), 'objects' );

foreach( $post_types as $post_type => $post_object ) {

    $messages[$post_type] = array(
        0  => '', // Unused. Messages start at index 1.
        1  => sprintf( __( '%s updated. <a href="%s">View %s</a>' ), $post_object->labels->singular_name, esc_url( get_permalink( $post_ID ) ), $post_object->labels->singular_name ),
        2  => __( 'Custom field updated.' ),
        3  => __( 'Custom field deleted.' ),
        4  => sprintf( __( '%s updated.' ), $post_object->labels->singular_name ),
        5  => isset( $_GET['revision']) ? sprintf( __( '%s restored to revision from %s' ), $post_object->labels->singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
        6  => sprintf( __( '%s published. <a href="%s">View %s</a>' ), $post_object->labels->singular_name, esc_url( get_permalink( $post_ID ) ), $post_object->labels->singular_name ),
        7  => sprintf( __( '%s saved.' ), $post_object->labels->singular_name ),
        8  => sprintf( __( '%s submitted. <a target="_blank" href="%s">Preview %s</a>'), $post_object->labels->singular_name, esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ), $post_object->labels->singular_name ),
        9  => sprintf( __( '%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>'), $post_object->labels->singular_name, date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ), $post_object->labels->singular_name ),
        10 => sprintf( __( '%s draft updated. <a target="_blank" href="%s">Preview %s</a>'), $post_object->labels->singular_name, esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ), $post_object->labels->singular_name ),
        );
}

return $messages;
}
add_filter( 'post_updated_messages', 'eg_custom_update_messages' );
share|improve this answer
    
Please add the relevant code into your answer, thanks. – birgire Sep 30 '15 at 13:58

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.