我正在研究一個插件,用於爲特定頁面添加自定義形式的Acuity調度。我想在一個特定頁面上的菜單和頁面標題之後添加調度表單。這裏是我當前的代碼:Wordpress Hook into page body
add_action('template_redirect', 'check_if_acuity_page');
function check_if_acuity_page(){
if(is_page('Schedule Page')){
add_action('add to acuity', 'display_acuity_scheduling_api');
}
}
function display_acuity_scheduling_api(){
echo '<div style="margin-top: 25px;">"Code to add Acuity Schedule to page"</div>';
}
「添加到視力」是目前我使用的是主題的header.php文件添加自定義操作掛鉤。它在當前頁面的頂部添加了時間表,所以我至少可以在適當的頁面上找到它,但它位於頁面的菜單和標題上方。我正在創建一個自定義佈局,並使用PHP代碼來修改頁面,具體取決於用戶選擇的內容,這就是爲什麼我不只是使用簡單的嵌入代碼。
我是新來的Wordpress的插件和掛鉤,所以我不知道我是否應該使用一個動作或過濾器掛鉤。任何幫助將非常感激。
function check_if_acuity_page(){
if(is_page('Schedule Page')){
echo '<div style="margin-top: 25px;">"Code to add Acuity Schedule to page"</div>';}
}
function add_code_before_content($content){
$acuity_page = check_if_acuity_page();
$content = $acuity_page.$content;
return $content;
}
add_filter('the_content','add_code_before_content');
希望這有助於:
http://stackoverflow.com/questions/3581510/wordpress-hook-直接後身標籤試試這個: –
你必須執行或添加? –
+ Raj Kumar Bhardwaj,我已經試過了,它只是把它放在頁面的最頂端。我需要它在頁面的菜單和標題下。 –