• I have a custom post type as part of a custom child theme and have customized the update messages with the following:

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

    This should be fine. However, when I go to any post, page, or other custom post type some of the itpeople update messages display in the upper left corner (under the admin bar and flush left). Specifically the message “Staff Memeber published. View staff member(as a link)” which is message 6. It does not display if I am in a post using the block editor. This is the HTML being displayed:

    <body class="wp-admin wp-core-ui js jetpack-connected  post-php auto-fold admin-bar post-type-post branch-5-2 version-5-2-2 admin-color-fresh locale-en-us customize-support svg">Staff Memeber published. <a href="http://edtech/adobe-premiere-basics-workshop/">View staff member</a>
    

    Note the post is not even of post type itpeople. This is how the HTML starts on an itpeople post:

    <body class="wp-admin wp-core-ui js jetpack-connected  post-php auto-fold admin-bar post-type-itpeople branch-5-2 version-5-2-2 admin-color-fresh locale-en-us customize-support svg">Staff Memeber published. <a href="http://edtech/people/vernon-zidana/">View staff member</a>
    

    The other thing is that “Thank you for creating with WordPress(a link).” is displayed about half way down the page on any page where this odd ball message is being displayed. I am at a loss as to what could be causing this. Any advice or steps to try and troubleshoot are appreciated.

    I’ve tried removing the text domain from the messages, removing the global $post and $post_ID, and adding REST to the post type.

    I have screenshots if needed.

Viewing 1 replies (of 1 total)
  • Thread Starter Jon Breitenbucher

    (@kahless)

    Never mind. I’m an idiot and just notice that message 6 says printf and not sprintf. Hopefully someone else benefits from this lesson in carefully checking your code. <facepalm>

Viewing 1 replies (of 1 total)
  • The topic ‘Odd issue with post_updated_messages’ is closed to new replies.