When visitors page through your calendar via Month View, it could be handy to provide them with a quick link to jump back to the current month.
In this tutorial, we'll look at adding just that. The final outcome should look a little like this:
Of course, though it wouldn't be harmful, the ideal would be for this new link to only display if the visitor is on something other than the current month.
Setting this up is actually pretty straightforward. First of all we're going to have to set up a template override for the month/nav.php template within your theme. To do this:
- Grab a copy of plugins/the-events-calendar/src/views/month/nav.php
- Place your copy in themes/YOUR_THEME/tribe-events/month/nav.php
Within this template you should be able to find the following lines of code:
These are responsible for displaying the previous and next month links. What we'll do in the middle of that code is insert the following snippet:
This simply checks to ensure the month being viewed is not the current month and, assuming it is not, provides a link to let visitors easily return to the current month. Your final template code should look something like this.
With a little imagination, the same technique could easily be applied to week, list or any other views.