Skip to content

Instantly share code, notes, and snippets.

@anag0
Created Jun 29, 2018
Embed
What would you like to do?
ASP: Remove duplicate titles
<?php
// ---- !!! ONLY COPY PASTE CODE BELOW THIS LINE to the functions.php in your theme directory !!! ----
add_filter('asp_results', 'asp_filter_duplicate_titles');
function asp_filter_duplicate_titles($results) {
$titles_arr = array();
foreach($results as $k=>&$r){
if ( isset($r->post_type) ) {
if ( $r->title != '' ) {
if ( in_array($r->title, $titles_arr) ) {
unset($results[$k]);
} else {
$titles_arr[] = $r->title;
}
}
}
}
return $results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment