Pretty Google Calendar Shortcode

Below, you’ll find a detailed guide on how to add the Pretty Google Calendar 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 Pretty Google Calendar Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Pretty Google Calendar Plugin and the shortcodes it provides:

Plugin Icon
Pretty Google Calendar

"Pretty Google Calendar is a user-friendly WordPress plugin that seamlessly integrates your Google Calendar with your website. It allows for easy event tracking and provides a visually appealing layout."

★★★★✩ (12) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [pretty_google_calendar]

Pretty Google Calendar [pretty_google_calendar] Shortcode

The Pretty Google Calendar shortcode is a tool that allows you to customize and embed a Google Calendar on your WordPress site. It offers customization options like locale, list type, view settings, and more. Additionally, it provides mobile view enforcement, tooltip usage, and link disabling. The calendar is loaded with an AJAX call for optimal performance.

Shortcode: [pretty_google_calendar]


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

  • gcal – Google Calendar’s unique identifier
  • locale – Sets the language for the calendar
  • list_type – Determines the type of list displayed
  • custom_list_button – Customizes the list button text
  • custom_days – Sets the number of days shown
  • views – Determines the calendar’s view options
  • initial_view – Sets the initial view when the calendar loads
  • enforce_listview_on_mobile – Enforces list view on mobile devices
  • show_today_button – Controls the visibility of the ‘Today’ button
  • show_title – Controls the visibility of the calendar’s title
  • id_hash – Unique identifier for the calendar
  • use_tooltip – Determines whether tooltips are used
  • no_link – Controls whether the events are clickable or not

Examples and Usage

Basic Example – Display a Google Calendar in English with the default view of ‘dayGridMonth’ and the list type as ‘listCustom’.

[pretty_google_calendar gcal="your_calendar_id" locale="en" list_type="listCustom" initial_view="dayGridMonth"]

Advanced Examples

Display a Google Calendar with a custom list button and custom days. In this example, the calendar will be in English, the list type will be ‘listCustom’, and the initial view will be ‘dayGridMonth’. The custom list button will display ‘My Custom List’ and the calendar will show events for the next 30 days.

[pretty_google_calendar gcal="your_calendar_id" locale="en" list_type="listCustom" initial_view="dayGridMonth" custom_list_button="My Custom List" custom_days="30"]

Display a Google Calendar with additional views and enforce list view on mobile. In this example, the calendar will be in English, the list type will be ‘listCustom’, and the initial view will be ‘dayGridMonth’. Additional views for ‘listDay’, ‘listWeek’, and ‘listYear’ will be available. The calendar will enforce the list view on mobile devices.

[pretty_google_calendar gcal="your_calendar_id" locale="en" list_type="listCustom" initial_view="dayGridMonth" views="dayGridMonth, listDay, listWeek, listYear" enforce_listview_on_mobile="true"]

Display a Google Calendar with tooltips and without links. In this example, the calendar will be in English, the list type will be ‘listCustom’, and the initial view will be ‘dayGridMonth’. Tooltips will be displayed for events, and the events will not contain links.

[pretty_google_calendar gcal="your_calendar_id" locale="en" list_type="listCustom" initial_view="dayGridMonth" use_tooltip="true" no_link="true"]

PHP Function Code

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

Shortcode line:

add_shortcode('pretty_google_calendar', 'pgcal_shortcode');

Shortcode PHP function:

function pgcal_shortcode($atts) {
  $default = array();
  $globalSettings = get_option('pgcal_settings', $default);

  $args = shortcode_atts(
      'gcal'                       => "",
      // 'locale'                     => $locale,
      'locale'                     => "en",
      'list_type'                  => "listCustom", // listDay, listWeek, listMonth, and listYear also day, week, month, and year
      'custom_list_button'         => "list",
      'custom_days'                => "28",
      'views'                      => "dayGridMonth, listCustom",
      'initial_view'               => "dayGridMonth",
      'enforce_listview_on_mobile' => "true",
      'show_today_button'          => "true",
      'show_title'                 => "true",
      'id_hash'                    => bin2hex(random_bytes(5)),
      'use_tooltip'                => isset($globalSettings['use_tooltip']) ? "true" : "false",
      'no_link'                    => isset($globalSettings['no_link']) ? "true" : "false",

  // Add the attributes from the shortcode OVERRIDING the stored settings
  $pgcalSettings = $args;

  if ($pgcalSettings['use_tooltip'] === "true") {


  // Load Local Scripts

  // Load Styles

  $script = "
    document.addEventListener('DOMContentLoaded', function() {
      function pgcal_inlineScript(settings) {
        var ajaxurl = '" . admin_url('admin-ajax.php') . "';
        pgcal_render_calendar(settings, ajaxurl);

      pgcal_inlineScript(" . json_encode($pgcalSettings) . ");
  wp_add_inline_script('pgcal_loader', $script);

  $shortcode_output = "
  <div id='pgcalendar-" . $pgcalSettings["id_hash"] . "' class='pgcal-container'>" . esc_html__("loading...", "pretty-google-calendar") . "</div>
  <div class='pgcal-branding'>" . esc_html__("Powered by", "pretty-google-calendar") . " <a href=''>Pretty Google Calendar</a></div>

  return $shortcode_output;

Code file location:



Now that you’ve learned how to embed the Pretty Google Calendar 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.


Leave a Reply

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