Show search terms and result counts in WordPress
Apr 20, 2025 am 07:03 AMIn this tutorial, we will share how to add a simple feature on the search page that will display the search terms and the number of results. This feature is a special request made by one of our users via email. If you want us to discuss a topic, feel free to make suggestions.
Open the search.php file in the theme and add the following code:
<h2 class="pagetitle">Search Results for<?php /* Search Count */$allsearch= newWP_Query("s=$s&showposts=-1"); $key= wp_specialchars($s, 1); $count= $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo$key; _e('</span>'); _e('— '); echo$count. ' '; _e('articles'); wp_reset_query(); ?></h2>
Depend on
Use it with one click in WordPress
The above code will display the following:
Twitter search results—15 articles
You can also highlight search terms by adding the .search-terms CSS class to the stylesheet of the topic. Here is a simple CSS to get started:
.search-terms {background-color:yellow;color:blue;}
Depend on
Use it with one click in WordPress
This is just one of the cool things you can do for search pages when customizing them. You can also highlight search terms in the results, and even add a search by category feature in WordPress search.
The above is the detailed content of Show search terms and result counts in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Airdrops in the cryptocurrency field are a marketing promotion method for the project to distribute a certain number of tokens for free to community members or potential users. In this way, the project party hopes to increase the visibility of the tokens and attract more users to participate in the project, thereby expanding the size of the community and increasing the liquidity of the tokens. For users, airdrops provide opportunities to obtain project tokens without initial investment, and are one of the ways to get in touch with and understand new projects in the early stage.

The latest official version of the virtual currency trading platform v6.129.0 is a professional and secure digital asset trading application created for Android users. It provides rich market conditions, convenient trading functions and multiple security protection, and is committed to providing users with a first-class trading experience.

Under the current severe regulatory environment, the difficulty of directly applying for a specific business license is increasing day by day, and the success rate is not ideal. Many platforms have therefore fallen into development bottlenecks. This article will analyze in detail an efficient "curve approval" strategy, aiming to help you understand how to obtain the required license through indirect compliance. This article will explain its operational process and core points in steps, providing you with a feasible compliance path.

The steps for downloading and installing Ouyi Eu official APP are as follows: 1. Click the download link provided by the official to download; 2. Confirm the download operation on the device; 3. Wait for the download to be completed. The installation steps are: 1. Find the download file in the notification bar or file manager; 2. Click the installation file to start the installation; 3. If the prompt is an unknown source application, you need to go to Settings to temporarily allow installation; 4. Click the "Install" button to wait for the installation to be completed; 5. After the installation is completed, click "Open" to start the APP. Follow the above steps to complete the download and installation.

The currency circle seems to have a low threshold, but in fact it hides a lot of terms and complex logic. Many novices "rush into the market" in confusion and end up losing money. This article will give a comprehensive explanation of common terms in the currency circle, the operating logic of real money makers, and practical risk control strategies to help readers clarify their ideas and reduce investment risks.

The Virtual Currency Trading APP is a professional digital asset trading platform, committed to providing users with a safe, stable and convenient trading experience. The application integrates real-time market trends, chart analysis, and multiple trading types to help users grasp market trends anytime, anywhere and make efficient investment decisions.

The top ten digital currency exchanges in the world in 2025 include Binance, Coinbase, OKX, etc., ranking by comprehensive strength. 1.Binance is known for its multilingual support and high liquidity; 2.Coinbase is suitable for entry-level users and has strong compliance; 3.OKX provides spot and contract trading; 4.Bybit is known for derivative trading; 5.Kraken has a good security record; 6.Bitget focuses on order trading; 7.KuCoin focuses on innovative currencies; 8.Gate.io has a variety of currencies; 9.MEXC is fast to launch new products; 10.HTX focuses on Asian markets. Core comparison dimensions show that Binance, OKX and Coinbase are the best liquidity; Coinba

HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams.
