This part is tricky:
..except for child pages and parent pages, if the parent has 2 or more children
Something that might help is the [pass] shortcode, which you can use to pass the ID of the current post in the loop.
[loop ..]
[pass field=id]
[-loop ..]
[if empty]
[--loop type=page id={FIELD}]
..
[/--loop]
[/if]
[/-loop]
[/pass]
[/loop]
That looks pretty wild, so I’m not sure if it’s possible to do this with shortcodes.
Thank you for the response. I think I aimed a little too high making something fancy when it didn’t need to be so I’ll just keep children in my list.
I actually have a follow-up question. I’m currently displaying all my pages with two nested loops as follows:
‘
[loop type=”page” clean=”true” list=”true” exclude=”children”]
[field title-link]
[-loop parent=”this” clean=”true” list=”true”]
[field title-link]
[/-loop]
[/loop]
‘
However, this creates whitespace between each bullet point. It appears the space occurs because I am entering the second loop on every bullet point, even if there are no children. Is there a way to check if a given page is a parent before going into the loop, or remove this whitespace another way?
Hi mockingbirdAlex,
this creates whitespace between each bullet point
This sounds like an issue with the post content being automatically formatted. You can avoid it by using [raw] shortcode (must be enabled in settings):
[raw]
..the whole code block..
[/raw]
..or by putting the code in one line where you don’t want any line breaks:
[loop type="page" clean="true" list="true" exclude="children"][field title-link][-loop parent="this" clean="true" list="true"][field title-link][/-loop][/loop]