# Querying a custom post type, but not show duplicates

I have a custom post type created called 'classes'. Within there i have a taxonomy set up as a category, so because of this there can be multiple occurrences of classes. Example:

Cat 1:
Class 1
Class 2

Cat 2:
Class 1
Class 3

Cat 3:
Class 3
Class 4

Where there is the 2 occurrences of 'Class 1' for example, they are 2 separate posts, just with the same post name.

I then want to output the classes on their page, but not show duplicates of the post name.
The duplicate posts obviously have different slugs (for example: myurl.com/class-1 and then myurl.com/class-1-1), but i want to be able to only show one occurences of a post if the post name is the same.

Below is the simple query i have so far, but not sure how to not show duplicates.

<?php
$temp =$wp_query;
$wp_query= null;$wp_query = new WP_Query();
$wp_query->query("post_type=classes".'&paged='.$paged);
?>
<?php while ($wp_query->have_posts()) :$wp_query->the_post(); ?>


Ahh iv figured out a way to do this:

<?php
$args = array( 'post_type' => 'classes', 'orderby' => 'title', 'posts_per_page' => -1 );$the_query = new WP_Query( $args );$unique_titles = array();
if( $the_query->have_posts() ) : while ($the_query->have_posts() ) : $the_query->the_post();$title = get_the_title();
if( ! in_array( $title,$unique_cities ) ) :
$unique_titles[] =$title;
?>