WordPress Shortcode: Show Today’s Weton Anywhere on Your Site

You run a blog about Javanese culture, a community site, or a personal page dedicated to your heritage. You want to add an authentic, dynamic touch—displaying the current Javanese Weton day. But how? This guide will show you exactly how to create a simple Weton WordPress plugin, complete with a shortcode and a widget, even if you’re not a professional developer.

By Ky Tutur, Javanese Culturalist •
Published on September 30, 2025

The Javanese Weton is a living calendar, giving each day a unique energy that guides everything from weddings to personal reflection. With a Weton WordPress plugin, you can display the current day dynamically, connecting visitors to Javanese culture in real time. A Weton WordPress plugin handles the calculation automatically, so your site always shows the correct day. Using a Weton WordPress plugin brings authenticity and interactivity to any Javanese-focused website.

Instead of searching endlessly for a pre-made solution, why not build your own Weton WordPress plugin? Creating a Weton WordPress plugin from scratch is simpler than it seems. This guide walks you through the core logic of the Javanese calendar and shows how to turn it into a fully functional Weton WordPress plugin. You’ll learn how to display the current day using a shortcode or a sidebar widget, making your site dynamic. By the end, you’ll have a Weton WordPress plugin that brings authentic Javanese heritage to any WordPress page.

Why Build a Weton WordPress Plugin? The Power of Dynamic Content

A static website is like a history book; a dynamic website is like a conversation. Displaying the current Weton day transforms your site from a passive source of information into an active participant in the Javanese calendar. It shows your visitors that your connection to the culture is alive and current. A plugin is the perfect way to achieve this. It’s a self-contained piece of code that adds new functionality to WordPress without altering the core files, a best practice outlined in the official WordPress Plugin Developer Handbook. Our simple plugin will do one thing and do it well: calculate and display the current Weton.

Part 1: The Logic – How the Weton is Calculated

Before we write any code, we need to understand the math. The Javanese calendar system, or *penanggalan Jawa*, combines several cycles. For our Weton, we need two:

  • The 7-Day Week (Saptawara): This is the familiar weekly cycle (Senin/Monday, Selasa/Tuesday, etc.).
  • The 5-Day Market Week (Pancawara or Pasaran): This is the uniquely Javanese cycle of Legi, Pahing, Pon, Wage, and Kliwon.

The Weton is the combination of these two cycles, like Senin Legi. A Weton WordPress plugin can calculate this automatically, using a known starting point or epoch. By entering a date, the Weton WordPress plugin figures out how many days have passed and finds the correct day in each cycle. This Weton WordPress plugin makes the complex calculation simple and accurate for your website.

An infographic showing two interlocking gears, one with 7 cogs (Saptawara) and one with 5 cogs (Pancawara), to illustrate the Weton calculation.
An infographic showing two interlocking gears, one with 7 cogs (Saptawara) and one with 5 cogs (Pancawara), to illustrate the Weton calculation.
The Weton is the combination of the 7-day and 5-day cycles, a calculation our plugin will perform automatically.

Part 2: Building the Plugin from Scratch

Now, let’s turn that logic into a functional WordPress plugin. All you need is a simple text editor.

Step 1: Create Your Plugin File

First, create a new folder on your computer and name it something like `weton-display`. Inside that folder, create a new file named `weton-display.php`. Open this file in your text editor and add the following code at the very top. This is the official plugin header that tells WordPress what your plugin is.

<?php
/**
 * Plugin Name:       Javanese Weton Display
 * Plugin URI:        https://en.kaweruhjawa.com/weton-wordpress-plugin
 * Description:       Displays the current Javanese Weton day via a shortcode or widget.
 * Version:           1.0
 * Author:            Ky Tutur
 * Author URI:        https://en.kaweruhjawa.com
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       weton-display
 */

Step 2: The Core Calculation Function

Next, we’ll create the main function that does the Weton calculation. This function will be the engine of our plugin. Add the following code to your `weton-display.php` file below the header.

function get_current_weton_data() {
    // Arrays for the day names
    $saptawara = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'];
    $pancawara = ['Pahing', 'Pon', 'Wage', 'Kliwon', 'Legi'];

    // Set the time zone to Jakarta (Western Indonesia Time)
    date_default_timezone_set('Asia/Jakarta');

    // Get today's date
    $today = new DateTime();

    // Our epoch (known starting point). Jan 1, 1970 was a Kamis Kliwon.
    $epoch = new DateTime('1970-01-01');

    // Calculate the difference in days
    $interval = $today->diff($epoch);
    $days_since_epoch = $interval->days;

    // Calculate the index for each cycle
    // Epoch day indexes: Kamis = 4, Kliwon = 3
    $saptawara_index = ($days_since_epoch + 4) % 7;
    $pancawara_index = ($days_since_epoch + 3) % 5;

    // Get the names
    $day_name = $saptawara[$saptawara_index];
    $pasaran_name = $pancawara[$pancawara_index];

    return [
        'day' => $day_name,
        'pasaran' => $pasaran_name,
        'full_weton' => $day_name . ' ' . $pasaran_name
    ];
}

Step 3: Creating the Shortcode

Now that we have a function to get the data, we need a way to display it. A shortcode is the perfect tool. Add this code to your file.

function weton_shortcode_function() {
    $weton_data = get_current_weton_data();
    return '<div class="weton-display">Today is: <strong>' . esc_html($weton_data['full_weton']) . '</strong></div>';
}
add_shortcode('todays_weton', 'weton_shortcode_function');

This code does two things: it creates a function that gets the Weton data and formats it into a nice HTML string, and then it registers `[todays_weton]` as the shortcode that will run this function.

Part 3: How to Install and Use Your Plugin

With the code complete, it’s time to install and use your new creation.

Installation Steps:

  1. Take the `weton-display` folder you created and compress it into a `.zip` file.
  2. Log in to your WordPress dashboard. Navigate to Plugins > Add New.
  3. Click the Upload Plugin button at the top of the page.
  4. Choose the `weton-display.zip` file you just created and click Install Now.
  5. Once installed, click Activate Plugin.

That’s it! Your plugin is now active.

Using the Shortcode

Using your new shortcode is incredibly simple. Just open any page, post, or text widget in WordPress and type the following:

[todays_weton]

When you publish or view the page, WordPress will automatically replace that shortcode with the current Weton day, like “Today is: Selasa Pon“.

A screenshot of the WordPress editor with the [todays weton] shortcode, and the front end view showing the rendered Javanese day.
A screenshot of the WordPress editor with the [todays weton] shortcode, and the front end view showing the rendered Javanese day.
Simply add the shortcode to any page or post to display the current Weton.

Going Further: Creating a Sidebar Widget

For even more flexibility, we can add a drag-and-drop widget. This is more advanced, but the code is straightforward. Add this final block of code to your `weton-display.php` file. It creates a new Widget class that uses our same calculation function.

class Weton_Widget extends WP_Widget {

    public function __construct() {
        parent::__construct('weton_widget', 'Today\'s Javanese Weton', ['description' => 'A widget to display the current Weton day.']);
    }

    public function widget($args, $instance) {
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
        }
        $weton_data = get_current_weton_data();
        echo '<div class="weton-widget-display">Today is: <strong>' . esc_html($weton_data['full_weton']) . '</strong></div>';
        echo $args['after_widget'];
    }
    
    public function form($instance) {
        $title = !empty($instance['title']) ? $instance['title'] : 'Today\'s Weton';
        ?>
        <p>
        <label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
        <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>">
        </p>
        <?php
    }

    public function update($new_instance, $old_instance) {
        $instance = [];
        $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
        return $instance;
    }

}

function register_weton_widget() {
    register_widget('Weton_Widget');
}
add_action('widgets_init', 'register_weton_widget');

After saving this code (and re-zipping/uploading your plugin if needed), you can now go to Appearance > Widgets in your WordPress dashboard. You will see a new widget called “Today’s Javanese Weton” that you can drag into your sidebar, footer, or any other widget area.

Conclusion: A Living Connection to Javanese Culture

You’ve done it. You have successfully built a functional Weton WordPress plugin that connects tradition with technology. This Weton WordPress plugin turns your site into a living reflection of the Javanese calendar, moving it beyond a static archive into a dynamic cultural space. By adding the shortcode or widget from the Weton WordPress plugin, you share a touch of living heritage that feels personal and engaging. Whether your visitors are part of the diaspora seeking connection or newcomers exploring Javanese wisdom, the Weton WordPress plugin makes the experience more authentic.

This project is a perfect first step into the world of WordPress development and a wonderful way to blend modern technology with ancient heritage. Now that you can display the Weton, you can dive deeper into its meaning with our guides to the Weton system and Neptu numbers.