SearchWP

News

How to add shortcode results to WordPress

Are you wondering how to include shortcode results in a WordPress search?

Shortcodes are quite popular among the WordPress community. They allow website owners to show dynamic content in any post, page, or sidebar with a few clicks.

Not everyone knows, but shortcodes often contain a lot of useful search-oriented content. Unfortunately, the default WordPress search engine doesn’t consider it.

In this step-by-step guide, we’ll show you how to include shortcode results in WordPress search.

What Are WordPress Shortcodes?

Shortcodes are code snippets enclosed in square brackets. They usually consist of one or two words and some numbers.

Here is an example:

Shortcode example

The most common place to use them is a post or page. Yet, you can place a shortcode at any location where you can add code through the WordPress editor.

The list of available shortcodes is determined by the theme or plugins that you use on your website.

For example, it might be a gallery plugin’s shortcode that adds a photo gallery to a post. A shortcode that adds a search box to a sidebar. A table shortcode, or anything else. There are tons of possible options.

The best thing is that you don’t even need to be a web developer or tech-savvy person to use them.

Сheck the list of available shortcodes supported by your theme or installed plugins. You can usually find them either on the plugin or theme description page, or on their official website.

Add a shortcode to the page, and that’s it! Once WordPress finds the shortcode, it automatically runs the code associated with it.

Here’s an example of how a shortcode of one of the popular gallery plugins looks in the post editor:

How the WordPress shortcode looks like

And here is like it displays on a website:

WordPress gallery displayed by a shortcode

By using shortcodes, you can do things that a web developer normally does.

Why Add Shortcode Results to WordPress Search?

By default, WordPress only indexes the text within the shortcode’s brackets, like this:

[gallery id="12" columns="4"]

Generally, this is a bunch of random words and numbers. It hardly makes sense to include that in a search, doesn’t it?

But, what if we make WordPress index the content that displays on a website instead of a shortcode? It’s definitely going to be much more beneficial!

Here are some popular use cases when including shortcode results can be helpful:

  • Sites with a lot of galleries: you can make searchable file names, descriptions, and alt text of the images that they contain. It improves image discoverability, which is especially helpful for portfolios and cooking blogs.
  • Sites made with a page builder: most of the popular page builders actively use shortcodes. Visitors won’t find anything on a page created with such a builder if you don’t make them searchable.
  • Sites with tables and charts: by default, data in tables and charts displayed using shortcodes don’t appear in WordPress search results. It can lead to a lot of disappointed visitors who quit a site after they don’t find what they’re looking for.

Shortcodes may contain a lot of content that can be useful to make searchable in many scenarios.

As we figured that out, let’s take a look at how you can add shortcode results to search in WordPress.

How to Include Shortcode Results in WordPress Search

The fastest and easiest way to include shortcode results in WordPress search is to use a plugin like SearchWP.

SearchWP Poster for Twitter

As the best search plugin for WordPress, SearchWP allows you to make searchable almost anything on your website. Shortcodes, documents, and custom fields are a part of the list.

SearchWP also has automatic integration with any WordPress theme. So, you get an enhanced search right after you activate the plugin with just a few clicks.

Here are some other features that make it one of the most powerful WordPress search plugins:

  • Support of taxonomies, custom fields, and documents: SearchWP doesn’t only include shortcode results in search. Using this plugin, you can make almost anything searchable on your website.
  • Seamless integration with WooCommerce: WooCommerce stores the product details as custom fields. Using SearchWP, you can make WordPress consider them while searching. It helps your visitors to find your products easier and faster.
  • On-site search activity insights: SearchWP collects all the data about visitors search activity on your website. This is a unique opportunity to get new content ideas.

Let’s take a look at how you can include shortcode results in a WordPress search in 3 simple steps.

Step 1: Install and Activate SearchWP

The very first step you need to do is grab your copy of SearchWP here.

After getting the plugin, you can download it on the Downloads tab in your account dashboard.

SearchWP downloads

Once you get to it, press the Download SearchWP button.

SearchWP download button

After grabbing your copy of SearchWP, you’ll receive an email with the plugin license key. Copy the key to the clipboard or save it to notepad, as you will need it soon to activate the plugin.

Next, log into your WordPress website admin area and upload the SearchWP ZIP file.

If you need any help with that, you can check out this step-by-step guide on how to install a WordPress plugin.

Once the plugin is installed and activated, the next step is to activate the product license.

To do this, go back to your WordPress dashboard and click the SearchWP button that appears on the top bar.

Go to SearchWP settings

Then, go over to the License tab and enter the license key you got from the email. After entering the key, press the Activate button.

Activate your SearchWP license

Once you activate the plugin, start setting up the WordPress search engine.

Step 2: Add Shortcodes as Attributes in Your Search Engine

The WordPress search engine has its own ranking algorithm. You can consider the algorithm as a set of rules to which WordPress adheres when performing a search.

This set includes such parameters as to where to look for matches, which content attributes should be considered, and many more.

You can completely change the search algorithm to suit your needs by customizing these parameters.

Now, let’s make WordPress index shortcodes content while searching.

Go over to the Advanced tab in the SearchWP settings.

SearchWP advanced settings

Here you can find many useful options. By enabling or disabling them, you can customize your website’s search in the way you want.

To include shortcode results in WordPress search, check the appropriate box.

Include shortcodes to WordPress search

That’s it. You’ve successfully added shortcode results to WordPress search!

Step 3: Test Your New Search Results with Shortcodes

To test the improved WordPress search results, you need to leave the dashboard and go over to your website.

The fastest way to do this is to click the Visit Site button. You can find it under your site name in the upper left corner.

Visit WordPress website

Now you need to type anything related to the shortcode you use into the search bar.

For example, for this tutorial, we’ve created a gallery with soup pictures. Let’s check if WordPress search can find this gallery.

WordPress found an article

As you can see, everything works great. WordPress found an article that contains a picture of the shrimp soup.

The soup gallery

This is a great result, given the fact that the “shrimp” word is not mentioned either in the title or in the content of the article.

This works because WordPress now indexes the images’ alt text, even if they’re placed inside a gallery output by a shortcode.

From this article you learned how to include shortcode results in WordPress search. It opens up a lot of possibilities and helps your website visitors to explore your content.

If you’re ready to empower your WordPress search, you can grab your copy of Search WP here.

You can also check our guide on how to add Fuzzy search to WordPress if you want to make the search on your website more flexible.

Want WordPress to start consider PDF files while searching? Then check our guide on how to make WordPress index PDF files on your site.

Want to make your search awesome right now?

More than 30,000 sites have chosen SearchWP!

You can utilize all of the content that’s gone unrecognized by native WordPress keyword search instantly with SearchWP.

Get SearchWP for just $99

  • Committed Support
    If you need help, support is fast, friendly, and here for you
  • Streamlined Setup
    Installation and setup that’s optimized for speed
  • Great Documentation
    Helpful, clear, and usable documentation is a priority

See what SearchWP customers have to say

  • “SearchWP is the best of multiple search plugins I’ve tried. Running a complex content site, being able to rank types of content differently, or even have a separate search engine with its own index for a more specific part of the site, is invaluable.”

  • “SearchWP delivers the search experience WordPress should out of the box. The way it combs through Advanced Custom Fields (ACF) is class leading. It’s an excellent product and a terrific value.”

  • “We have been looking for a solution that also includes a similarity search and typo correction. With SearchWP we have found exactly that. Download, install, done.”