Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I don't want to edit core files in order to change the page where a user enters new posts, so is there a way to do it within a theme, perhaps within functions.php ..?

Specifically, I'm trying to change the wording of the 'Set featured image' text to something like 'Set featured image - 50 pixels by 50 pixels'

share|improve this question
1  
I'd just use jQuery. –  John P Bloch Sep 9 '10 at 13:56
    
I agree with John Bloch. Edit your functions.php of your theme to load an action event hook. This would need to detect one is in the admin mode. Then, once in admin mode, make it load jQuery and then make it activate your jQuery snippet. –  Volomike Sep 10 '10 at 5:24
    
I'm using a modification of this in a plugin and I'm running into difficulties (see here). Have you modified this for 3.0 successfully? Or do you have any thoughts as to what I need to do to make it work? –  Ghost1227 Sep 10 '12 at 17:13
add comment

2 Answers

up vote 10 down vote accepted

You can use the filter admin_post_thumbnail_html:

function custom_admin_post_thumbnail_html( $content ) {
    return $content = str_replace( __( 'Set featured image' ), __( 'Set featured image - 50 pixels by 50 pixels' ), $content );
}

add_filter( 'admin_post_thumbnail_html', 'custom_admin_post_thumbnail_html' );
share|improve this answer
add comment

One way is to use careful jQuery code inserted in the header of the admin to modify the text within a specific part of the page. You need to be able to target a specific div/span/html tag in order to do so, but this system will let you edit any part of the page even if there is no filter (though the answer by Sorich has a great filter for the use-case in your question, my answer applies more generally to your question itself).

I used the code below to alter the featured image box in 2.9 to say 'featured image' instead of 'post thumbnail' because the labels changed in 3.0 and I wanted my old site to use the new terminology before upgrading it.

Note that the code handles both the popup box and the metabox, and uses some jquery AJAX functions to ensure the content gets re-modded after pageloads in the iframe.

/**
 * Use jQuery to add context to the Featured Image metabox on post editing pages
 * and to change the label to be Featured Image instead of Post thumbnail in WP 2.9 
 * before the label changed.
 *
 * See javascript for info on removing these as they become part of the AP API
 */
function gv_admin_featured_image_tweaks() {
    ?>
<script type="text/javascript">
    jQuery(document).ready(function($) {
        /**
         * TEMPORARY: SWITCH VARIOUS LABELS TO SHOW FEATURED IMAGE INSTEAD OF POST THUMBNAIL
         * REMOVE WHEN 3.0 COMES OUT AND THIS IS THE DEFAULT LABEL
         */
        $('#postimagediv h3 span').text('Featured Image');
        // Only change the set thumbnail text if its that, otherwise we end up replacing the img tag when it is set
        if ($('#postimagediv #set-post-thumbnail').text() == 'Set thumbnail') {
            $('#postimagediv #set-post-thumbnail').text('Choose Featured Image');
        }
        $('#postimagediv #remove-post-thumbnail').text('Remove Featured Image');

        // label inside media item details in popup
        $('.wp-post-thumbnail').text('Use as Featured Image');
        // refresh inside media item for after upload finishes.
        $('body').ajaxComplete(function() {
            $('.wp-post-thumbnail').text('Use as Featured Image');
        });

        /**
         * Add a description of how we use featured images. should be replaced with a description parameter in the API
         */
        $('#postimagediv .inside').prepend('<p>This image will be used in the featured posts slider if this post is featured. It should be at least 400px wide by 300px tall.</p>');
    });
</script>
    <?php
}
add_action('admin_head', 'gv_admin_featured_image_tweaks');
share|improve this answer
add comment

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.