A few days ago, I added a “recent news” box to the front page of the site, which shows the most recent items posted in the News category. It’s the easiest way to find the most up to date news about the site or the C++ Tutorial.
Today when I was investigating how to make the box wider, I realized that I’d used the wrong CSS style in the newspage.php file, and consequently, the margins on the news box were being set equivalent to the width of the sidebars! Obviously that is not what I had intended!
The original style.php file did not have an appropriate style to use for this kind of addition, so I had to define my own. I also had to update the newspage.php file to use the new style. Then I figured, as long as I’m updating the style.php, I might as well make the margin parameter user-definable, so I modified the functions.php and added a parameter to the Tigarator. Consequently, the procedure below now has one more step, where you set the margin of the box through the Tigarator.
For you Tiga fans who would like to add your own recent news box to your Tiga-themed web site, here’s how you do it.
- First, install the customizable post listings plugin. This plugin is what does the work of listing the posts.
- Second, download the newspage page template and associated files, and extract them to a local directory. This newspage page template will only work with the Tiga theme. NOTE: If you’ve already hand-modified functions.php or style.php, this will overwrite your changes!
- Third, edit the newspage.php file with an editor (for Windows users, wordpad works fine). You will see a line that looks like this:
<ul><?php c2c_get_recent_posts(5, "<li>%post_date%: %post_URL%</li>", "4"); ?></ul>
Change the “4” to the category ID of the category you want the box to display posts from. If you want the box to display posts from multiple categories, change the “4” to a space separated list of category IDs.
- Upload the template into your wp-content/themes/tiga-06/ directory.
- Go to your WordPress Administrator. For each page you wish to have a recent posts box: Edit the page. On the right side, you should see a “Page Template” box. Select “Newspage”. Save your page.
- Go into the Tigarator (Presentation -> Tigarator). You will see a new option named “Inner Widget Margin”. This is the margin for the news box. Set an appropriate value, such as 50.
That’s it.