• Home »
  • »
  • WordPress: Display Pages Marked Private To All Users

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.

First locate the following line in the widgets.php file:
$out = qd_db_list_pages( array(‘title_li’ => ”, ‘echo’ => 0, ‘sort_column’ => $sortby, ‘exclude’ => $exclude) );[/quickcode]
and modify it by switching the first exclude to include like this:
$out = qd_db_list_pages( array(‘title_li’ => ”, ‘echo’ => 0, ‘sort_column’ => $sortby, ‘include’ => $exclude) );
After making this modification open up the WordPress administration page, click the Design tab, and then click the Widgets tab. Since it will already be in one of your sidebars locate it and click edit. Now just enter the PID’s (Page ID) you want to include such as: “3, 1406, 32”. Save the widget and refresh your site and now the only page links that will be included are the ones you have specified.

**NOTE** The WordPress Codex also lists other ways to accomplish the same goal bit if you have the same issue I did where you did not want to have to manually enter over 100 PID’s then the solution will work best.

WordPress For Dummies, 2nd Edition (Paperback)

List Price: $24.99
New From: $0.87 USD In Stock
Used from: $0.01 USD In Stock