2017-01-03 4 views
1

Ich bin Anfänger wp entwickeln ihn lernen, wie ich meine erste shortcode auf WordPress erstellen, so dass ein Benutzer, der Shortcode [contact_form] hinzufügen, Seite oder Post wird es auf jeder Seite ihres Themas zu sehen.Wordpress Issue Erstellen einer Shortcode

Hier Nachricht 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(); 

Antwort

1

Es ist einfach Ihre Formatierung

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

Sie nicht wissen, warum danken, dass verpassen. Ich habe noch eine Frage Ich habe ein Formular in contact-form.php erstellt, aber nicht auf der WordPress-Website enthalten. Zeigen Sie einfach das [Kontaktformular]. –

+0

müssen Sie eine neue Frage mit Ihrem Code stellen. Achten Sie auf den Pre-Content – David

Verwandte Themen