Support » Developing with WordPress » search form not working properly

  • Resolved bibliofille


    I’ve got a search form in the main nav of a site I’m building. For some reason, it’s not fully working. The search will only work if you try to pull up an exact page title. If you search for a name or a term on a page, it does not turn up any results. For example, there is a person named Beth listed on the About page, but when you search “Beth” in the search bar, it does not pull up any results.

    What could be the issue?

    Here’s a link to my test site: It’s got a password on it, just so the client can’t see it yet. It’s Cabrini2017!

    Here’s the code from header.php for the search form:

    <div class="search-dropdown" style="display: block;">
                <form method="get" id="searchform" action="<?php echo site_url(); ?>">
    	<input type="text" class="field" name="s" id="s" placeholder="What are you looking for?">
    	<button type="submit" class="submit" name="submit" id="searchsubmit"><i class="fa fa-search fa-lg"></i></button>

    Here’s the jQuery I’m using for the hide&show feature:

     /*Hide&Show search bar in header*/
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz


    By using the name “s” on the input form, you are invoking the default WP search functionality, which normally does search post content for term matches. If this is not happening, your theme or a plugin is altering the search functionality. Try deactivating all of your plugins. Retest the search, if content search is still not working, your theme is at fault. If it works, reactivate your plugins, one by one, testing after each. When the search fails again, the last activated plugin is at fault.

    Altering search functionality is usually done through a hook to “pre_get_posts”. If you can find where this is done, it can be undone.

    Thread Starter bibliofille


    Thanks for the tip. Hmm, I tried deactivating all the plugins, however, a lot of my content is served using ACF Pro, so when I deactivate that, there’s virtually nothing left to search, except a couple pieces of content that are hard coded within the template.

    But the search form should pick up that data since it’s stored in the database, no?

    I am using Bones as a starter theme, and I couldn’t find any place within functions.php or bones.php where it looked like the theme itself was altering search functionality.

    Moderator bcworkz


    Ah! The ACF content is likely what the problem is. The default WP search feature does not search ACF fields, it only searches post titles and what is actually in $post->post_content.

    To search ACF fields as well might be tricky. That is a question best asked in the dedicated ACF forum.

    Sorry about the misleading information in my initial reply.

    Thread Starter bibliofille


    Yep, the issue was ACF. I dug through their forums and found a reference to this helpful post:

    Worked like a charm!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘search form not working properly’ is closed to new replies.