[wp-trac] [WordPress Trac] #27326: wp_list_pages - exclude parameter changes behaviour depending on depth

WordPress Trac noreply at wordpress.org
Sun Jun 22 13:05:41 UTC 2025


#27326: wp_list_pages - exclude parameter changes behaviour depending on depth
-------------------------------------------------+-------------------------
 Reporter:  nosnurg                              |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:
Component:  Posts, Post Types                    |     Version:  3.8.1
 Severity:  normal                               |  Resolution:
 Keywords:  needs-refresh good-first-bug has-    |     Focuses:
  unit-tests needs-patch                         |
-------------------------------------------------+-------------------------
Changes (by SirLouen):

 * keywords:  has-patch needs-testing => needs-refresh good-first-bug has-
     unit-tests needs-patch


Comment:

 == Reproduction Report
 === Description
 ✅ This report validates that the issue can be reproduced.

 === Reproduction Instructions

 1. Add 3 parent pages
 2. Add 3 child pages to each of the 3 parent pages (9 children in total).
 Will look [https://i.imgur.com/1V8kLzH.png like this]
 3. Add the code in supplemental artifacts to a plugin, functions.php or
 wherever you can execute such code. Remember to edit the ID of 'exclude'
 to the ID of the 3rd parent page you created
 4. Add the shortcode [custom_pages_list] to a post
 5. Check the post results
 6. 🐞 The whole section of the parent excluded is removed.

 [[Image(https://i.imgur.com/ZGCnQUB.png)]]

 === Actual Results
 1. ✅ Error condition occurs (reproduced).

 === Additional notes

 It appears that the current bug is still valid in 2025. I've tried to
 apply this patch, seems not to be working (or I'm not applying as
 expected). Checking Unit tests, they seem to be correct, covering this
 bug. Wondering what happened with this report, general unit tests were
 added, but the report did not progress itself.

 cc @MikeHansenMe

 Anyway, just in case, given that the solution provided is almost done,
 including some tests, I believe this could be a suitable candidate for
 `good-first-bug`.

 === Supplemental artifacts

 Code for testing

 {{{
 function custom_pages_list_shortcode($atts) {
     $atts = array(
             'exclude' => '11', // ID of the 3rd parent to exclude
             'depth'   => '3',
             'echo'    => 0,
     );
     return wp_list_pages($atts);
 }
 add_shortcode('custom_pages_list', 'custom_pages_list_shortcode');
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/27326#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list