Skip to content

Instantly share code, notes, and snippets.

@isGabe
Last active February 25, 2019 21:28
Show Gist options
  • Select an option

  • Save isGabe/3094617 to your computer and use it in GitHub Desktop.

Select an option

Save isGabe/3094617 to your computer and use it in GitHub Desktop.
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
Copy link
Copy Markdown

good find. saved the day.

@MartinL83
Copy link
Copy Markdown

Thanks for sharing!

@rikardhassel
Copy link
Copy Markdown

Thanks!

@redbranchmedia
Copy link
Copy Markdown

Perfect! Thanks for putting this up

@gabointriago
Copy link
Copy Markdown

Nice!! thanks, it helped me alot

@swdimock
Copy link
Copy Markdown

swdimock commented Jan 5, 2015

Thanks for sharing! Nice solution.

@raulvinicius
Copy link
Copy Markdown

Genius! Thanks!

@fgilio
Copy link
Copy Markdown

fgilio commented Mar 1, 2015

Nice, thank you!

@pdmytrewycz
Copy link
Copy Markdown

I owe you a beer. Or three.

@EvanHerman
Copy link
Copy Markdown

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
Copy link
Copy Markdown

Thnx a lot EvanHerman.. :) (Y)

@bootlab
Copy link
Copy Markdown

bootlab commented Nov 7, 2015

Top Share :)

@brittanynavin
Copy link
Copy Markdown

Thank you! This saved me tons of time

@tripflex
Copy link
Copy Markdown

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