The file that is displaying the search result, is the search.php file from the main theme folder.
Below, you can find a working example that does the search of the default posts and pages:
'post_type' => array('post', 'page')
You can add a custom post in that array, for instance, if the custom post type has the ‘portfolio‘ name then add it to the array will be:
'post_type' => array('post', 'page', 'portfolio')
The whole search.php example:
<?php
/* The template for displaying Search Results pages.*/
get_header();
?>
<!-- main -->
<div id="main">
<!-- intro -->
<section class="intro">
<!-- search -->
<form action="<?php echo home_url(); ?>" method="get" class="search">
<fieldset>
<input type="text" name="s" id="s" value="<?php _e('Click or type here to search','text_domain'); ?>" class="text" >
<input type="submit" value="go" class="submit" >
</fieldset>
</form>
<p><?php printf( __( 'Search Results for: %s', 'text_domain' ), '<strong>' . get_search_query() . '</strong>' ); ?></p>
</section>
<div class="main-holder">
<!-- search results list -->
<section class="col" id="content">
<?php
$s = $_GET['s'];
$args=array(
'post_type' => array('post', 'page'),
'post_status' => 'publish',
's' => $s,
'orderby' => 'ID',
'order' => 'desc',
'paged' => $paged
);
$temp = $wp_query; // assign original query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
if ($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post();
$thumb_url = get_the_post_thumbnail($post->ID, '', array('alt' => the_title_attribute('echo=0')));
?>
<!-- article -->
<article class="article article-alt">
<div class="heading">
<h2><a href="https://wordpress.stackexchange.com/questions/261798/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
</div>
<nav class="add-info">
<ul>
<li><?php echo get_the_time('F d, Y'); ?></li>
<li class="data"><?php the_category(', ') ?></li>
<li class="data"><?php echo $cat_slug; ?></li>
<li><?php comments_popup_link(__('0 Comments', 'text_domain'),__('1 Comment', 'text_domain'), __('% Comments', 'text_domain')); ?></li>
</ul>
</nav>
<?php if ($thumb_url) { ?><figure class="visual"><?php echo $thumb_url; ?></figure><?php } ?>
<?php the_excerpt(); ?>
<a class="more" href="https://wordpress.stackexchange.com/questions/261798/<?php the_permalink(); ?>"><?php _e('Read more ...','text_domain'); ?></a>
</article>
<?php
endwhile;
else:
_e('<h2>Nothing Found</h2>','text_domain');
echo '<p>'.__( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'text_domain' ).'</p>';
endif;
?>
<!-- paging -->
<nav class="paging">
<ul>
<?php
if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
?>
</ul>
</nav>
<?php
$wp_query = null;
$wp_query = $temp;
?>
</section>
<!-- sidebar -->
<aside class="col" id="sidebar">
<?php dynamic_sidebar("Blog Sidebar") ?>
</aside>
</div>
</div>
<!--/ main -->