Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress: Custom placeholder text for custom post type title input box #snippet #WordPress
<?php
/*
replacing the default "Enter title here" placeholder text in the title input box
with something more descriptive can be helpful for custom post types
place this code in your theme's functions.php or relevant file
source: http://flashingcursor.com/wordpress/change-the-enter-title-here-text-in-wordpress-963
*/
function wpfstop_change_default_title( $title ){
$screen = get_current_screen();
if ( 'your_custom_post_type' == $screen->post_type ){
$title = 'Your custom placeholder text';
}
return $title;
}
add_filter( 'enter_title_here', 'wpfstop_change_default_title' );
?>
@nickberens360

This comment has been minimized.

Copy link

commented Oct 24, 2013

good find. saved the day.

@MartinL83

This comment has been minimized.

Copy link

commented Feb 15, 2014

Thanks for sharing!

@rikardhassel

This comment has been minimized.

Copy link

commented Mar 3, 2014

Thanks!

@redbranchmedia

This comment has been minimized.

Copy link

commented Mar 26, 2014

Perfect! Thanks for putting this up

@gabointriago

This comment has been minimized.

Copy link

commented Aug 4, 2014

Nice!! thanks, it helped me alot

@swdimock

This comment has been minimized.

Copy link

commented Jan 5, 2015

Thanks for sharing! Nice solution.

@raulvinicius

This comment has been minimized.

Copy link

commented Feb 27, 2015

Genius! Thanks!

@fgilio

This comment has been minimized.

Copy link

commented Mar 1, 2015

Nice, thank you!

@pdmytrewycz

This comment has been minimized.

Copy link

commented Mar 5, 2015

I owe you a beer. Or three.

@EvanHerman

This comment has been minimized.

Copy link

commented Sep 24, 2015

I would like to propose a change to this, as to prevent any errors from being thrown. You should first check that the post type object is being set inside of $screen.

function wpfstop_change_default_title( $title ) {
    $screen = get_current_screen();
    if( isset( $screen->post_type ) ) {
        if ( 'your_custom_post_type' == $screen->post_type ) {
            $title = 'Your custom placeholder text';
        }
    }
    return $title;
}
add_filter( 'enter_title_here', 'wpfstop_change_default_title' );
@MilanSavaliya

This comment has been minimized.

Copy link

commented Oct 13, 2015

Thnx a lot EvanHerman.. :) (Y)

@bootlab

This comment has been minimized.

Copy link

commented Nov 7, 2015

Top Share :)

@bvacchiano

This comment has been minimized.

Copy link

commented Mar 17, 2016

Thank you! This saved me tons of time

@tripflex

This comment has been minimized.

Copy link

commented Mar 22, 2016

Here's one I adapted for the WP Editor placeholder: https://github.com/tripflex/wp-tinymce-placeholder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.