0

I'm wondering what is the proper way to use depth n in wp_list_pages. I currently have a menu in my sidebar that goes 4 levels deep but I'd like to prevent levels 3 & 4 from displaying.

The codex says:

'depth'

(int) Number of levels in the hierarchy of pages to include in the generated list. Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to the given n depth). Default 0.

I've tried:

wp_list_pages('child_of=124&title_li&depth=n(2)')
wp_list_pages('child_of=124&title_li&depth=n2')

I can't seem to find any examples on how to use depth in this instance.

5
  • 1
    depth=n2 should be depth=2 Commented Apr 13, 2016 at 16:12
  • 1
    n is just a "placeholder" and should be replaced by the actual integer value Commented Apr 13, 2016 at 16:14
  • 1
    Thanks...I guess I was thinking like css with nth-child().
    – brandozz
    Commented Apr 13, 2016 at 16:44
  • My pleasure, enjoy ;-) Commented Apr 13, 2016 at 16:45
  • @PieterGoosen as an answer please :)
    – Rarst
    Commented Apr 13, 2016 at 16:59

1 Answer 1

1

depth=n2 should be depth=2. n is just a "placeholder" and should be replaced by the actual integer value of your choice

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.