If you would want to write a phrase in single or plural form depending on a number, there is a very handy function for it written in WordPress called _n. The function also takes a $domain argument which can be handy when localizing plugins or themes.
In your search template you might want to print “Found X results matching your query”. When X is above 1 you want to write “results” but if there only was a single result found you would want to write “result”.
This can be accomplished with the following code:
<?php printf( __( 'Found %d %s matching your query: %s' ), $wp_query->found_posts, _n( 'result', 'results', $wp_query->found_posts), get_search_query() ); ?>
Leave a Reply