再製做wordpress theme的時候一定會碰到一些客製上的東西

比方說客戶要求寄信表單的所需內容物

或者某些地方想要套用自己的CSS

這時候就要用add_filter()的方式來處理囉

參數

add_filter

 tag=要hook的參數名稱function_to_add=要客製的參數priority=優先權accepted_args=參數數量 )

先找到function.php的檔案(或者是自己製作一個)

以下是一些剛好這次碰到的一些指令

the_password_form (輸入密碼表單

<?php
function custom_password_form() {
global post;
label = 'pwbox-'.( empty( post->ID ) ? rand() : post->ID );
o = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
' . __( "This post is password protected. To view it please enter your password below:" ) . '
<label for="' . label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . label . '" type="password" size="20" />
<input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';
return o;
}

add_filter( 'the_password_form', 'custom_password_form' ); ?>

 

 

contextual_help (後台上方說明文件

<?php
function my_plugin_help(contextual_help, screen_id, screen) {

contextual = 'hello world' ;
return contextual_help;
}

add_filter('contextual_help', 'my_plugin_help', 10, 3);
?>

 

更多hook 可以在這邊找

文章標籤
全站熱搜
創作者介紹
創作者 JEFF 的頭像
JEFF

起飛點 Flydots Design

JEFF 發表在 痞客邦 留言(0) 人氣(179)