Ticket #1669 (closed enhancement: fixed)
Patch to "wp_list_pages" to add the opposite of "exclude" (called "only")
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.1 |
| Component: | General | Version: | 1.5.2 |
| Severity: | normal | Keywords: | exclude, only, opposite bg|has-patch bg|dev-feedback bg|squashed |
| Cc: |
Description
The diff below will add the opposite functionality of "exclude" to the wp_list_pages. This means instead of excluding all but 1 page, you can choose to ONLY show that one page. This way, no matter what you add in the future it will never have to be messed with to exclude it.
--- wp-includes/template-functions-post.php.old 2005-09-11 09:02:35.000000000 -0400 +++ wp-includes/template-functions-post.php 2005-09-11 08:56:30.000000000 -0400 @@ -287,6 +287,20 @@
}
}
}
+ if (!empty($ronly?)) { + $onlypages = preg_split('/[\s,]+/',$ronly?); + if (count($onlypages)) { + foreach ($onlypages as $onlypage) { + if (!empty($exclusions)) { + $exclusions .= ' OR '; + } else { + $exclusions .= ' AND '; + } + echo $onlypages[$onlypage]; + $exclusions .= ' ID = ' . intval($onlypage) . ' '; + } + } + }
$pages = $wpdb->get_results("SELECT * " .
"FROM $wpdb->posts " .
Attachments
Change History
comment:3
markjaquith — 6 years ago
- Keywords bg|has-patch bg|dev-feedback added
- Owner changed from anonymous to markjaquith
- Status changed from new to assigned
Thanks! I can't tell you how many people have asked me if this was possible.
- Status changed from assigned to closed
- Resolution set to fixed
This ticket is resolved by changeset:3655 that added the ability to include a selected page or pages in function get_pages(). So, with wp_list_pages(), a parameter of 'include=3,4' will present just pages IDs 3 and 4.
Guess it's okay to change this to fixed even though it is assigned to Mark, and request bg's mark as Closed.


Added it into a code block to make its formatting "nicer"
--- wp-includes/template-functions-post.php.old 2005-09-11 09:02:35.000000000 -0400 +++ wp-includes/template-functions-post.php 2005-09-11 08:56:30.000000000 -0400 @@ -287,6 +287,20 @@ } } } + if (!empty($r['only'])) { + $onlypages = preg_split('/[\s,]+/',$r['only']); + if (count($onlypages)) { + foreach ($onlypages as $onlypage) { + if (!empty($exclusions)) { + $exclusions .= ' OR '; + } else { + $exclusions .= ' AND '; + } + echo $onlypages[$onlypage]; + $exclusions .= ' ID = ' . intval($onlypage) . ' '; + } + } + } $pages = $wpdb->get_results("SELECT * " . "FROM $wpdb->posts " .