Family Encyclopedia >> Electronics

Display search term and number of results in WordPress

In this tutorial we will share how you can add a simple function on your search page that will display the search term and the number of results. This feature was a special request from one of our users via email. If you'd like us to cover a topic, feel free to make a suggestion.

Display search term and number of results in WordPress

Open your search.php file in your theme and add the following code:

 

Resultado de la búsqueda por post_count; _e ("); _e (''); echo $ key; _e (''); _e ('-'); echo $ count."; _e ('artículos'); wp_reset_query (); ?>

The code above will display something like this:

twitter search results - 15 items

You can also highlight the search term by adding the Search Terms CSS class to your theme's style sheet. Here's some simple CSS to get you started:

 .términos de búsqueda color de fondo: amarillo; color azul; 

This is just one of the best things you can do for your search page when you customize it. You can also highlight search terms in the results and even add a category search feature to your WordPress search.

Source:Michael Martin