Code Snippets

WordPress NextGen Gallery – Add Date Print Out to Compact Album Listings

I was working on my personal blog and wanted to add the date or a date range to the top of each gallery when they are listed out. The blog I am speaking of uses WordPress, WP version 2.7, with the NextGen Gallery plugin, NGG version 1.2.1, for pictures. I list the all of the galleries by using the album compact function so the below howto relates to that function only. What it will do is simply print out anything in the description field right above the image you have highlighted for each gallery. Since I was not using the description for anything else I just add the date or a date range into that field such as 01-01-2009 or 04-16-2009 to 08-10-2009.  Follow the directions below and you can print out anything you like above each gallery listing.

The NextGen Gallery shortcode used to display the galleries:

php

  1. [album=3,compact]

Technology Insights

Modify The WordPress Pages Widget to Include Pages Instead of Exclude Pages

Recently I was setting up a WordPress blog and needed to use the default pages widget to list a certain set amount of pages. On this blog I used the NextGEN Gallery for dozens of different galleries. The issue was that I wanted to only list a couple of pages using the default Pages widget and when using NGG I would have dozens if not hundreds of pages that I would need to exclude with the default Pages widget. So what I needed to do was include a couple of page ID’s¬†instead of excluding hundreds of page ID’s.

The problem above can be accomplished by making one minor adjustment to one WordPress file. We will need to modify the wp_pages_widget PHP function to include the pages specified in the admin versus excluding them.

File to Modify: <wp-root-directory>/wp-includes/widgets.php
Line: 682