Help ordering custom query by Title, Ascending

I think you need to read up a bit on how The Loop works in WordPress:
https://codex.wordpress.org/The_Loop

And how the WP_Query class:
https://codex.wordpress.org/Class_Reference/WP_Query

I am assuming your only want 2 loops, at the moment your have 3.

  1. On line 19, which stores its posts in a var $query then does nothing.

  2. On line 21, which is your main unaltered loop.

  3. On line 54, which your colleague helps you with? Seems to be working.

So what you need to do is pass the arguments from your first loop to your second loop instead.

You can do this by making a new WP_Query like you did on line 53.

$query = get_posts( $args ); // line 19

becomes:

$query = new WP_Query( $args );

and Loop through the results using the have_posts() function.

if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); // line 21