WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/posts distinct

Description

The filter eliminates duplicates in your search results.

Usage

The following example shows how to use the filter in a plugin:

function search_distinct() {
	return "DISTINCT";
}
add_filter('posts_distinct', 'search_distinct');

If you return an empty string from the filter, duplicates will continue to show. For example:

function search_distinct() {
	if ( $this->allow_duplicates )
		return ""; // filter has no effect
	return "DISTINCT";
}
add_filter('posts_distinct', 'search_distinct');

Notes

Returning "DISTINCTROW" from the filter has the same effect on the query as "DISTINCT".

This page is marked as incomplete. You can help Codex by expanding it.