無意中發(fā)現(xiàn)這個有趣的wp鉤子,這個鉤子的主要用處是在WordPress撰寫文章頁面添加一段提示標(biāo)語的功能,用法也很簡單,只需要把下面的代碼放在functions.php文件中就行,內(nèi)容改成你需要的。
function tips_text_after_title($post_type) { ?>
<div class="after-title-help postbox">
<h3>這是一段文本提示語句的測試</h3>
</div>
<?php }
add_action( 'edit_form_after_title', 'tips_text_after_title' );
效果如下
感興趣的朋友可以測試下,不過這段提示語會出現(xiàn)在頁面編輯里面,如果只想在文章內(nèi)出現(xiàn)或者自定義分類的文章內(nèi)出現(xiàn),則可以用下面的代碼,代碼中product是自定義分類
function tips_text_after_title($post) {
if( 'post' !== $post->post_type && 'product' !== $post->post_type ) {
return; } ?>
<div class="after-title-help postbox">
<h3>特色圖片尺寸為600*430</h3>
</div>
<?php }
add_action( 'edit_form_after_title', 'tips_text_after_title' );