Brandon Powell
Brandon Powell

Reputation: 105

Wordpress Issue creating a shortcode

I'm beginner wp developing him learning how to create my first shortcode on WordPress so a user that add shortcode [contact_form] to Page or Post will see it on any page of their theme.

Here Message 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();

Upvotes: 1

Views: 1022

Answers (1)

David
David

Reputation: 5937

Its just your formatting

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

Upvotes: 1

Related Questions