WPFTS Pro Main Site WPFTS Community Forum
    • Recent
    • Tags
    • Popular
    • Register
    • Login
    Get WPFTS Pro today with 25% discount!

    How to search posts by shortcode content in Wordpress?

    Scheduled Pinned Locked Moved Recipes and Known Solutions
    featureindexingsearchshortcode
    1 Posts 1 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • EpsilonAdminE
      EpsilonAdmin
      last edited by EpsilonAdmin

      When you ever try to search WordPress posts or pages by shortcode content inserted to posts, you should notice that it's a not trivial task!

      Simply say, it's not possible for the native WordPress search. And you even can not solve this by simple PHP code. But why? Well, let me explain to you in detail.

      Shortcodes are tags like [the_shortcode] included in the post content. Lots of plugins use this technique to insert their custom (and sometimes quite complex) content into the post, and this powerful functionality really makes the difference to us!

      But why we can't search in that generated content? Because the shortcode content is never stored in the database. Instead, only the [the_shortcode] string is stored. WordPress page generation function is creating the text for shortcodes "on the fly". But native WP search is working with the database data!

      Okay... so it's not possible, right?

      No way! Since the WPFTS plugin is indexing, it does provide the ability to store "generated" shortcode content in the search index together with the post content! And thus, posts/pages become searchable by the shortcode content!

      Let me give you an example.

      Assume we have a post with the content like this:

      The cats always have their wonderful and useful devices like [cats_devices].

      As you can see, this content has the shortcode, which will be replaced by the string "fluffy paws, long tail, furry back, and purr" on the page generation stage. But only the initial content will be stored in the database.

      Assume you want to find this post by the word "tail" using an integrated WP search. You will find... nothing!

      Now listen, what the WPFTS plugin does: at the moment when you save your post, it renders the post content as it should look on the frontend - with all these shortcodes rendered and then store the result in the search index!

      Later, when you're trying to search for the word "tail", it will return the post ID, because it knows - the "tail" will be on the page!

      E20201119-051309-001[1].png

      And even more - this full phrase will be shown in the Smart Excerpt. Cool, right?

      The respective option was added to the WPFTS Settings / Indexing Engine / Indexing Defaults tab and it is enabled by default, but who knows, just be sure you have this enabled to use this cool feature!

      E20201119-045918-001[1].png

      You don't need for Pro version to try this cool functionality: shortcode content search is available in the basic (free) version of WPFTS.

      Hope this post made your day. Or an hour. Or at least minute 🙂

      https://e-wm.org

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      Suggested Topics

      • EpsilonAdminE

        Is it possible to make 2 different searches on the same website?

        Watching Ignoring Scheduled Pinned Locked Moved Frequently Asked Questions multiple search widgets presets filters
        1
        1 Votes
        1 Posts
        898 Views
        No one has replied
      • EpsilonAdminE

        [Solved] Indexing and Search files by content in BuddyDrive

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions buddydrive file search
        1
        0 Votes
        1 Posts
        727 Views
        No one has replied
      • EpsilonAdminE

        How to search coupons by description in WP Coupons and Deals plugin

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions wpcd coupons deals
        1
        0 Votes
        1 Posts
        678 Views
        No one has replied
      • EpsilonAdminE

        [Solved] The plugin shows wrong results for search with BeTheme template

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions betheme theme
        1
        0 Votes
        1 Posts
        793 Views
        No one has replied
      • EpsilonAdminE

        [Solved] How to index new posts which was added by the script?

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions reindex script search
        1
        0 Votes
        1 Posts
        730 Views
        No one has replied

      Additional Resources

      • My Account
      • Buy WPFTS Pro
      • Community Forum
      • Affiliate Program
      • Privacy Policy
      • Terms & Conditions
      • Contact Us
      • Coupon Partner

      Be the first to read the news!

      We are always improving our products, adding new functions and fixes. Subscribe now to be the first to get the updates and stay informed about our sales! We are not spammy. Seriously.

      Join Us Now!

      We are a professional IT-team. Many of us have been working in a Web IT field for more than 10 years. Our advanced experience of software development has been employed in the creation of the WordPress FullText Search plugin. All solutions implemented into the plugin have been used for 5 or more years in over 60 different web-projects.

      We are looking forward to your comments, requests and suggestions in relation to the current plugin and future updates.

      ewm-logo-450

      The forum powered by NodeBB | Contributors