The if test is testing to see whether there actually are any child posts. If there are any, then wp_list_pages is called again, with echo = 1 (true – the default) to actually output the child posts.
You could generalize this to test for some other condition (such as the existence of a specific page name), do the if test, and if true, output the result by calling wp_list_pages again with echo = 1. Or, say, you want to display the child posts of ID 2 only if there are child posts of ID 1. It’s a bit inefficient, requiring two calls to the same function, but it would do the job.
Currently I have a hardcoded include that is currently at 7 IFs and SubPages and will increase. It would be nice to use the database and WP to help me with this.
Perhaps, is there a plugin that allows more, if not complete, control of how the links are outputted without having to edit the template-functions-post.php file?
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘wp_list_pages and its echo’ is closed to new replies.