Skip to content

Instantly share code, notes, and snippets.

@spencejs
Created March 22, 2013 03:35
Show Gist options
  • Save spencejs/5218759 to your computer and use it in GitHub Desktop.
Save spencejs/5218759 to your computer and use it in GitHub Desktop.
Add Instruction Text To Featured Image Box In Wordpress Admin
@r-interactive
Copy link

jezremy

Hi jezremy ,

the code works, but how can I do this for multiple Custom post types. I want each custom post type featured image box to have different instructions. I am having trouble coding the if else statement, seems that get_post_type() doesn't work.

This is what I have:

`function change_post_type_labels() {

		if('news' == get_post_type()){
			$post =  'news';
			$text = 'Set featured image (540px x 350px)';

		}elseif( 'page' == get_post_type()){
			$post = 'page';
			$text = 'Set featured image (600px x 300px)';
		}

		$post_object = get_post_type_object( $post);

		if ( ! $post_object ) {
					return false;
		}

		$post_object->labels->set_featured_image =  $text;
		return true;

}

add_action( 'wp_loaded', 'change_post_type_labels', 20 );`

Would you know what the issue is?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment