Support

Account

Home Forums Front-end Issues Checking custom posts in repeater loop breaks the repeater Reply To: Checking custom posts in repeater loop breaks the repeater

  • Your problem is that you have multiple nested queries.

    • The main WP Query
    • $scheduleloop
    • $adloop

    when you use wp_reset_postdata() at the end of the $adloop loop WP is resetting to the post in the main query, not the post in the $scheduleloop query. This function always resets to the main query.

    You can try $scheduleloop->reset_postdata()

    But I do not think this will work because $scheduleloop will be undefined in the second include.

    Even if defined you will have an issue if that template is included from multiple places so you wouldn’t know what query you need to reset. My suggestion here would be to use get_template_part() instead of include(locate_template(...)) and pass the query to be reset as an argument.