您可以为TinyMCE生成的文本区域设置占位符文本吗wp_editor()
?
http://codex.wordpress.org/Function_Reference/wp_editor http://codex.wordpress.org/Function_Reference/wp_editor
我的代码目前是:
$settings = array( 'media_buttons' => false );
wp_editor( $content, $editor_id, $settings );
这会生成一个包含所有功能的文本区域,例如 TinyMCE 按钮和 Quicktags,但我不知道如何设置占位符文本。使用标准文本区域,您可以这样做:
<textarea name="content" placeholder="Write something"></textarea>
以下内容不会为您提供 HTML5"placeholder"
属性为您的文本区域,但它会给您一些要显示的文本而不是空框:
我认为通常您会通过传递它需要的所有片段来使用 wp_content ,如下所示:
wp_editor( stripslashes($content), $editor_id, $settings );
(变量$content
是一个字符串,可以从数据库或从$_POST
数组等)
所以我建议您在致电之前wp_content()
函数,测试是否$content
是空的,如果您发现确实是空的,那么您可以使用占位符内容为其播种:
if( strlen( stripslashes($content)) == 0) $content = "Write something";
wp_editor( stripslashes($content), $editor_id, $settings );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)