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

The latest version of Digital Currency Exchange 2025 is a world-leading digital asset trading application, committed to providing users with secure, stable and convenient trading services for mainstream digital currencies such as Bitcoin and Ethereum. Its simple and intuitive operation interface and powerful functional modules make it easy for both novices and senior traders to get started.

As an important digital asset hard forked from the original Ethereum blockchain, Ethereum Classic (ETC) has always been the focus of market attention. After experiencing ups and downs in early development and multiple technological iterations, ETC still occupies a place in the global cryptocurrency market with its unique decentralized spirit and smart contract platform functions. There are many factors that affect ETC prices, including but not limited to macro trends in the entire cryptocurrency market, ETC’s own network upgrades and security, community activity, changes in regulatory environments, and the attitudes of institutional investors.

Ethereum, as one of the blockchain platforms with leading market value and the most active ecosystem, has attracted much attention. It is not only a digital asset, but also the cornerstone of innovation fields such as decentralized applications, smart contracts, decentralized finance (DeFi) and non-fungible tokens (NFT). Predicting its future price trend is a complex process, affected by the interweaving of multiple factors such as technological development, macroeconomic environment, regulatory policies, market sentiment and network itself upgrade.

Dogecoin (DOGE), a digital asset originating from the Internet subculture, has occupied a place in the crypto market with its unique community culture and wide popularity. For many market participants, predicting their price movements over a specific time period in the future is challenging but attractive. This article aims to deeply analyze the key factors that may affect Dogecoin’s market value from 2025 to 2030 and explore its potential development path.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

As July 2025 approaches, the crypto market is hotly discussing which tokens may bring high returns. Are names like Pi, PEPE and FloppyPepe really worth the risky investment? Potential cryptocurrencies worth paying attention to in July 2025: virtual fire or real gold? As mid-2025, the heat of discussions on high-yield crypto assets continues to heat up. Bitcoin trends and "altcoin season" expectations have attracted investors' attention. Do tokens like PiNetwork, PEPE and FloppyPepe have the potential to bring considerable investment returns? Let's analyze its prospects one by one. Altcoin Market: Can July get what it wants? Against the backdrop of Bitcoin’s expected record of historical highs, the “altcoin season” seems to be brewing. Back

The latest version of Binance is 2.101.8, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.
