Support » How-To and Troubleshooting » Recursive Post Loop

Recursive Post Loop

  • I would like to set up a page so that the post titles and excerpts from a category show with the child titles and excerpts listed after each previous level excerpt.

    Level 1 Title/Excerpt 1

    Level 1 Title/Excerpt 2
    Level 2 Title/Excerpt 1
    Level 2 Title Excerpt 2

    Level 1 Title/Excerpt 3

    That calls for recursion, but if I understand WP_Query correctly, setting up a second WP_Query inside the first would overwrite the first. Is that true?

Viewing 1 replies (of 1 total)
  • No you can nest multiple loops and queries within each other. You just need to make sure and keep track of each of them. If you are using WP_Query use a different variable to hold the query object for each loop so nothing gets overwritten. When you finish a loop make sure you call wp_reset_postdata();

Viewing 1 replies (of 1 total)
  • The topic ‘Recursive Post Loop’ is closed to new replies.