Can I make the Swiftype WordPress plugin search only posts?

Yes, the Swiftype WordPress plugin supports filters that allow you to customize what is returned with search results.

To search only the “post” type, add this filter to your functions.php:

function swiftype_search_params_filter( $params ) {
    // set the types to allow
    $params['filters[posts][object_type]'] = array( 'post' );

    return $params;
}

add_filter( 'swiftype_search_params', 'swiftype_search_params_filter', 8, 1 );

To limit autocomplete results to only the “post” type, add this action to change the autocomplete JavaScript configuration to your functions.php (take care to change the**<?php ... ?>** nesting as appropriate for your functions.php file):

function swiftype_javascript_config() {
?>
<script type="text/javascript">
var swiftypeConfig = {
  filters: {
    posts: {
      object_type: ["post"]
    }
  }
};
</script>
<?php
}

add_action('wp_head', 'swiftype_javascript_config');

Note that this requires your theme to have a wp_head function call. Most themes do, but if not you can add the JavaScript code directly to your template in the <head></head> section.

For more details, read our WordPress search result customization tutorial.

NOTE: It is recommended to install your theme customizations into a child theme so that your changes are not overwritten on theme upgrades.