Bandsintown Events Shortcode

Below, you’ll find a detailed guide on how to add the Bandsintown Events Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Bandsintown Events Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Bandsintown Events Plugin and the shortcodes it provides:

Plugin Icon
Bandsintown Events

"Bandsintown Events is a WordPress plugin that seamlessly integrates your Bandsintown concerts into your website. Display upcoming gigs, sell tickets, and enhance fan engagement with ease."

★★★✩✩ (8) Active Installs: 5000+ Tested with: 5.9.8 PHP Version: false
Included Shortcodes:
  • [bandsintown_events]

Bandsintown Events [bandsintown_events] Shortcode

The Bandsintown Events shortcode is a powerful tool for displaying artist events on your WordPress site. It allows customization of various attributes like artist name, text color, link color, background color, display limit, and more. This shortcode fetches event data based on the artist name provided. If no artist name is given, it defaults to the options set in the plugin settings. It also allows for customization of visual elements like color and font. If these are not specified, it again defaults to the plugin’s settings. Furthermore, the shortcode can handle additional attributes like separator color, widget width, display logo, and more. These attributes are omitted if left blank. The generated output is an anchor tag with all the data attributes filled in, providing a flexible and customizable way to display Bandsintown events.

Shortcode: [bandsintown_events]

Parameters

Here is a list of all possible bandsintown_events shortcode parameters and attributes:

  • artist – specifies the artist’s name for the event.
  • artist-name – another way to specify the artist’s name.
  • text-color – sets the text color in the widget.
  • link-color – defines the color of the links.
  • link-text-color – sets the color of the text within links.
  • background-color – sets the widget’s background color.
  • popup-background-color – sets the background color of popups.
  • separator-color – sets the color of separators in the widget.
  • font – sets the font for the text in the widget.
  • widget-width – defines the width of the widget.
  • display-logo – controls whether to display the artist’s logo or not.
  • display-track-button – controls whether to display the track button or not.
  • display-local-dates – shows local dates if set to true.
  • display-past-dates – shows past dates if set to true.
  • display-lineup – controls the display of the lineup in the event.
  • display-details – controls the display of event details.
  • display-limit – sets a limit on the number of displays.
  • language – sets the language for the widget.
  • auto-style – if true, widget style is adjusted automatically.
  • div-id – specifies the ID of the div element.
  • facebook-page-id – sets the ID of the related Facebook page.
  • afill-code – sets the affiliate code for tracking purposes.
  • app-id – sets the application ID for the widget.

Examples and Usage

Basic example – Displaying the events of a specific artist by using the artist’s name as a parameter.

[bandsintown_events artist="The Beatles" /]

Advanced examples

Displaying the events of a specific artist with customized colors and limit to the number of events displayed. The ‘link-color’ parameter changes the color of the links, ‘text-color’ parameter changes the color of the text and ‘display-limit’ parameter limits the number of events displayed.

[bandsintown_events artist="The Beatles" link-color="#FF0000" text-color="#0000FF" display-limit="5" /]

Displaying the events of a specific artist with additional parameters. The ‘display-local-dates’ parameter set to ‘true’ will display local dates, ‘display-past-dates’ parameter set to ‘false’ will hide past dates and ‘display-details’ parameter set to ‘true’ will show event details.

[bandsintown_events artist="The Beatles" display-local-dates="true" display-past-dates="false" display-details="true" /]

Displaying the events of a specific artist with custom widget width. The ‘widget-width’ parameter allows you to set a custom width for the widget.

[bandsintown_events artist="The Beatles" widget-width="300px" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [bandsintown_events] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('bandsintown_events', array($this, 'shortcode'));

Shortcode PHP function:

function shortcode($atts) {
    $default_atts = array(
      'artist' => '',
      'artist-name' => '',
      'text-color' => '#000000',
      'link-color' => '#2F95DE',
      'link-text-color' => '#FFFFFF',
      'background-color' => '#FFFFFF',
      'popup-background-color' => '#FFFFFF',
      'separator-color' => '',
      'font' => '',
      'widget-width' => '',
      'display-logo' => '',
      'display-track-button' => '',
      'display-local-dates' => 'false',
      'display-past-dates' => 'true',
      'display-lineup' => '',
      'display-details' => '',
      'display-limit' => '15',
      'language' => '',
      'auto-style' => 'false',
      'div-id' => '',
      'facebook-page-id' => '',
      'afill-code' => '',
      'app-id' => ''
    );

    $atts = shortcode_atts($default_atts, $atts);

    $artist_name = !empty($atts['artist']) ? $atts['artist'] : $atts['artist-name'];

    if (empty($artist_name)) { $artist_name = $this->options['artist']; }

    $atts['artist-name'] = htmlentities($artist_name);
    unset($atts['artist']);

    $has_default_background_color = $atts['background-color'] == $default_atts['background-color'];
    if ($has_default_background_color && !empty($this->options['background_color'])) {
      $atts['background-color'] = $this->options['background_color'];
    }

    $has_default_display_limit = $atts['display-limit'] == $default_atts['display-limit'];
    if ($has_default_display_limit && !empty($this->options['display_limit'])) {
      $atts['display-limit'] = $this->options['display_limit'];
    }

    $has_default_link_color = $atts['link-color'] == $default_atts['link-color'];
    if ($has_default_link_color && !empty($this->options['button_and_link_color'])) {
      $atts['link-color'] = $this->options['button_and_link_color'];
    }

    $has_default_link_text_color = $atts['link-text-color'] == $default_atts['link-text-color'];
    if ($has_default_link_text_color && !empty($this->options['link_text_color'])) {
      $atts['link-text-color'] = $this->options['link_text_color'];
    }

    $has_default_text_color = $atts['text-color'] == $default_atts['text-color'];
    if ($has_default_text_color && !empty($this->options['text_color'])) {
      $atts['text-color'] = $this->options['text_color'];
    }

    // These atts should be omitted altogether if they are blank
    foreach (
      array(
        'separator-color',
        'font',
        'widget-width',
        'display-logo',
        'display-lineup',
        'display-details',
        'display-track-button',
        'language',
        'div-id',
        'facebook-page-id',
        'afill-code',
        'app-id'
      ) as $a) {
      if (empty($atts[$a])) {
        unset($atts[$a]);
      }
    }

    $output = '<a class="bit-widget-initializer" ';

    foreach ($atts as $att => $value) {
      $output.= 'data-' . $att .'="' . $value . '" ';
    }

    $output.= '></a>';

    $options = get_option('bitp_options');

    if (!empty($options['custom_css'])) {
      $output .= '<style type="text/css">' . $options['custom_css'] . '</style>';
    }

    return $output;
  }

Code file location:

bandsintown/bandsintown/bandsintown.php

Conclusion

Now that you’ve learned how to embed the Bandsintown Events Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *