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

Technology Insights

WordPress: Display Pages Marked Private To All Users

When I was initially attempting to do this it was because I did not want to display a majority of the WordPress pages I was creating in the navigation or in the Pages Widget. After some research I located information on the WordPress Codex about how to exclude certain pages however this was not going to work for me since I would constantly be having to modify the exclude list with hundreds more than if I could just include the pages I wanted to show in the navigation. Inside the [wp-root]/wp-includes/widgets.php  file you can make a small modification followed by a change via the WordPress admin GUI.