2017-01-03 52 views
1

我是初學者WP開發他學習如何WordPress的創建我的第一個簡碼,以便添加簡碼[contact_form]頁面或帖子,用戶將看到其主題的任何頁面上。WordPress的問題創造一個簡碼

這裏留言 Parse error: syntax error, unexpected 'add_shortcode' (T_STRING), expecting function (T_FUNCTION) in /Users/brandonpowell/sites/valet/wordpress-development/web/app/themes/sage-8.5.0/lib/shortcode.php on line 16

<?php 

class Settings { 
     // Conact Form shortcode 
     public function allb_contact_form($atts, $content = null ) { 
     //[contact_form] 
     //get the attribute_escape 
     $atts = shortcode_atts(
      array(), 
      $atts, 
      'contact_form' 
     ); 
      //return HTML 
      include 'lib/inc/thmeplates/contact-form.php'; 

    add_shortcode('contact_form', 'allb_contact_form'); // Line 16 
    } 
new Settings(); 

回答

1

它只是您的格式

class Settings { 
     // Conact Form shortcode 

    public function allb_contact_form($atts, $content = null ) { 
      //[contact_form] 
      //get the attribute_escape 
      $atts = shortcode_atts(
      array(), 
      $atts, 
      'contact_form' 
     ); 
      //return HTML 
      include 'lib/inc/thmeplates/contact-form.php'; 

     add_shortcode('contact_form', 'allb_contact_form'); // Line 16 
    } 

}// this was missing 
+0

謝謝不知道爲什麼錯過。我還有一個問題,我在contact-form.php裏創建了一個表單,但沒有包含在WordPress網站上。只需顯示[contact_form]。 –

+0

您需要提出一個顯示您的代碼的新問題。注意預先獲取內容的鉤子 – David