Blog

  • The Events Calendar List Widget Replacement

    I wrote a plugin to customize the Events List widget that ships with Modern Tribe’s The Events Calendar Pro plugin. The widget has an option to hide completely when there are no upcoming events. The alternative displays the dreaded “There are no upcoming events at this time” in an otherwise empty Events List widget. I love the idea of not including the widget at all if there are no events, but what if this is the only widget in a sidebar or widget area? Sometimes, I want to display something in place of the widget instead of leaving the space empty. Here’s a plugin that does exactly that.

    Download plugin

    https://github.com/csalzano/the-events-calendar-list-widget-replacement

    Where does the replacement content live?

    Create a file at wp-content/themes/your-theme/tribe-events/pro/widgets/list-widget-replacement.php that contains the content you wish to display in place of the Events List widget when there are no upcoming events.

    If you’re using the free version of The Events Calendar, create the file at wp-content/themes/your-theme/tribe-events/widgets/list-widget-replacement.php

    (This file sits right next to list-widget.php, the template you might create to modify the output of the Events List widget. I chose these locations in the spirit of The Events Calendar Themer’s Guide.)

    Here’s what my file looks like–I wrote some HTML that mimics a widget so I didn’t have to write any additional CSS styles for the replacement content. My client is a local municipality, so I put together some numbers that describe the size and age of a small Pennsylvania township.

  • Editing Terms & Term Meta with the WordPress REST API

    Here are some JavaScript snippets to manipulate WP_Term objects in WordPress using the REST API and the Backbone JavaScript client library.

    Insert a term

    Delete a term

    This next example assumes you’ve used wp_localize_script() to make the REST API endpoint and a nonce available in an object myplugin. If you need help doing this, please leave a comment below and I’ll expand this example.

    Edit a term meta value

    Let’s add a term meta value to identify the number of speeds in this automatic transmission.

    Thanks for reading. If you know a better way to edit terms and term meta in JavaScript, please leave a comment below.