Skip to content

Instantly share code, notes, and snippets.

@certainlyakey
Last active March 16, 2018 11:37
Show Gist options
  • Save certainlyakey/f08597d24fa6966f6d7a308e3d20639f to your computer and use it in GitHub Desktop.
Save certainlyakey/f08597d24fa6966f6d7a308e3d20639f to your computer and use it in GitHub Desktop.
Add a placeholder to TinyMCE editor (Wordpress)
<?php
function set_mce_editor_placeholder_question($textarea_html) {
if ('question' !== get_post_type()) return $textarea_html;
$placeholder = __( 'Please enter some text as the question...', 'site_domain');
$textarea_html = preg_replace( '/<textarea/', "<textarea placeholder=\"{$placeholder}\"", $textarea_html );
return $textarea_html;
}
add_filter( 'the_editor', 'set_mce_editor_placeholder_question' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment