WordPress 3.5 新增了一对非常有用的挂钩,可以快速在WordPress后台文章编辑器的上方或下方添加提示内容,下面是一个简单的例子,直接将代码添加到主题的 functions.php 文件:
|
|
<span style="color: #000000; font-weight: bold;">function</span> below_the_title<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'<h3>在编辑器上方添加的提示内容</h3>'</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> add_action<span style="color: #009900;">(</span> <span style="color: #0000ff;">'edit_form_after_title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'below_the_title'</span> <span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">function</span> below_the_editor<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'<h4>在编辑器下方添加的提示内容</h4>'</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> add_action<span style="color: #009900;">(</span> <span style="color: #0000ff;">'edit_form_after_editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'below_the_editor'</span> <span style="color: #009900;">)</span><span style="color: #339933;">;</span> |
|
function below_the_title() {
echo ‘<h3>在编辑器上方添加的提示内容</h3>’;
} add_action( ‘edit_form_after_title’, ‘below_the_title’ );
function below_the_editor() {
echo ‘<h4>在编辑器下方添加的提示内容</h4>’;
} add_action( ‘edit_form_after_editor’, ‘below_the_editor’ );
结果如下图所示:

参考资料:http://www.doitwithwp.com/add-a-message-above-or-below-the-post-editor/
赏 如果本文对你有帮助,请打赏作者,鼓励我们继续写作!
请先
!