I'm working on an adoption site and the company has a database that contains all their adoptive families.

I have a page that contains a small line of shortcode which pulls every family within the database onto that page, about 39 pages with 10 families per page. That link can be found here: http://lifetimeadopt.staging.wpengine.com/all-adoptive-families/

If you click on any of those family's profile, you will go to a family page which dynamically pulls the info for whichever family you have clicked.

I want to use the Search widget to allow a visitor to Search through the list of all adoptive families within the database by keyword. For example, searching 'soccer' would pull every family that mentioned soccer in their description.

However, the WP Search widget will not find any of the content within the family's page because it is dynamically generated.

The code for the widget is thus, but, obviously, it will not show up with any results:

<section class="widget search-2 widget_search"><h6>Search Lifetime:</h6><form role="search" method="get" class="search-form form-inline" action="http://lifetimeadopt.staging.wpengine.com/all-adoptive-families">
  <label class="sr-only">Search for:</label>
  <div class="input-group">
    <input type="search" value="" name="s" class="search-field form-control">
    <span class="input-group-btn">
      <button type="submit" class="search-submit btn btn-default">Search</button>

Does anybody know of any workarounds or edits I could make to have the WP Search widget properly index the content for each family, even though it is dynamic?

1 Answer 1


Are families a custom post type? If so, they won't be included in the default WP search. Try adding this to your theme's functions.php

function lauren_include_post_types_in_search($query) {
    if(is_search()) {
        $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false), 'objects');
        $searchable_types = array();
        if($post_types) {
            foreach( $post_types as $type) {
                $searchable_types[] = $type->name;
        $query->set('post_type', $searchable_types);
    return $query;
add_action('pre_get_posts', 'lauren_include_post_types_in_search');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.