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