2

Currently I am trying to remove duplicate iterations from my post loop, and it seems that my code is working perfectly the only issue is that my &posts_per_page=21 declare is no longer present, it displays only 3 results for example (which are the unique titles)

$args = array(
  'post_type'     => 'post',
  'order'         => 'ASC',
  'orderby'       => 'title'
);
$the_query = new WP_Query( $args );
$unique_artist = array();
query_posts($query_string.'&cat=7&posts_per_page=21'); if ( have_posts() ) : while ( have_posts() ) : the_post();

// title example for post "Artist - Song Name"
$title = get_the_title();
$artist = explode('-', $title);
$main_artist = $artist[0];

$aArtist = $main_artist;
if( ! in_array( $aArtist, $unique_artist ) ) :
    $unique_artist[] = $aArtist;

    the_title(); 

endif;  endwhile; endif;

How can I make it so that no matter what, my post_per_page will display the 21 desired results? Instead of only showing the unique titles, when we remove the duplicates..

Nosajimiki
  • 1,073
  • 1
  • 9
  • 17

0 Answers0