Created
May 5, 2016 15:50
-
-
Save kellenmace/25d51a2ebee4ca3b066598ba1e6d47a6 to your computer and use it in GitHub Desktop.
Change featured image title and link text in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Change the featured image metabox title text | |
*/ | |
function km_change_featured_image_metabox_title() { | |
remove_meta_box( 'postimagediv', 'my_post_type_name', 'side' ); | |
add_meta_box( 'postimagediv', __( 'NEW TITLE TEXT', 'km' ), 'post_thumbnail_meta_box', 'my_post_type_name', 'side' ); | |
} | |
add_action('do_meta_boxes', 'km_change_featured_image_metabox_title' ); | |
/* | |
* Change the featured image metabox link text | |
* | |
* @param string $content Featured image link text | |
* @return string $content Featured image link text, filtered | |
*/ | |
function km_change_featured_image_text( $content ) { | |
if ( 'my_post_type_name' === get_post_type() ) { | |
$content = str_replace( 'Set featured image', __( 'NEW SET TEXT HERE', 'km' ), $content ); | |
$content = str_replace( 'Remove featured image', __( 'NEW REMOVE TEXT HERE', 'km' ), $content ); | |
} | |
return $content; | |
} | |
add_filter( 'admin_post_thumbnail_html', 'km_change_featured_image_text' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment