possibly related:
https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Exclude_Pages_from_Search_Results
please read the full article https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
for example,
to show only static page results in search, try:
function search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('post_type', 'page');
}
}
}
add_action('pre_get_posts','search_filter');
Thread Starter
qnkov
(@qnkov)
Like that or? If that’s the point, it does not work.
<?php
global $SMTheme;
get_header();
?>
<h1 class='page-title'><?php echo sprintf($SMTheme->_('searchresults'),get_search_query()); ?></h1>
<?php
if (!have_posts()) { ?>
<div class="entry">
<p><?php echo $SMTheme->_( 'nothingfound' )?></p>
</div>
<?php }
get_template_part('theloop');
?>
<?php get_template_part('navigation'); ?>
function search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('post_type', 'page');
}
}
}
add_action('pre_get_posts','search_filter');
<?php
get_footer();
?>
please read the full article https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
the suggested code belongs for example in functions.php of your (child) theme