Posted by ve9gra | Filed under Tutorials
As it seems that instructions for a proper integration in WordPress are a bit scattered across a few posts and have to be gleaned to make up something that you can use, I figured it would be a good idea to create a multi-part tutorial that centralizes everything. In this first part, we’ll add the calendar to your sidebar. The next part will be how to create a page to integrate something like the TOC, or the List mode. And for the last one, we’ll go deep and create a custom Blog mode integration.
This tutorial will make some assumptions, like your WordPress is installed in your web root (not in a sub-folder), and you already have the calendar installed in the /calendar folder. Also, in order to be able to perform the integration, you have to make sure that the calendar uses the same database as your WordPress installation.
Let’s start easy with setting up the proper permalink structure. Go to your WP administration interface, in the Settings section, and then Permalinks. You will have to use the “Default” setting. This is so that the calendar navigation work. Using any of the other modes and you will not be able to navigate to different months.
Now, we’re getting into the guts of things. Here, you can use the Theme Editor, but I strongly suggest that you do not. Instead modify the actual files. All of the files that are modified are in your /wp-content/themes/<your theme>.
The first file to edit is your header.php so that we can add the CSS code required for the calendar. Find the </head> tag and then add the following code just before it.
<?php $CSS=1; require("calendar/calendar.php"); ?>
Now, for this step, you need to find the file that has the <body> tag. I can’t tell you which file to look in, but in my case it was also in the header.php file. Simply find the <body> tag and add this code just after it. This is required if you want to make use of the mouse-over popups.
<?php $OL=1; require("calendar/calendar.php"); ?>
And as the last step for this tutorial, we’ll add the calendar to the sidebar. So, open up your sidebar.php and copy one of the entries that make up the block. Here’s an example from my theme:
<h3>Categories</h3> <ul> <?php wp_list_categories('title_li='); ?> </ul>
Yours will probably be a bit different, but you get the idea. Then, using that, simply modify it a bit in order to display the calendar.
<h3>Calendar</h3> <ul> <?php require("calendar/calendar.php"); ?> </ul>
This concludes this first part of the tutorial. We’ll keep coming back to this one as it will be the basis to many modifications.
In case you missed the other posts in this series, please go to:
- How to integrate the calendar in WordPress (Part 2) – Integrating the TOC in a page
- How to integrate the calendar in WordPress (Part 3) – Redirecting the sidebar calendar to the TOC page