How to avoid the specific page while searching in WordPress without plugin?
Question
I am using WordPress search which is working but I am getting one issue on the search result.
My issue is, when I search my product then I am getting the output but it also displaying the privacy policy results.
Example
Displaying result code
<section id="primary" class="content-area mainSearch">
<main id="main" class="site-main">
<div class="equalPadding">
<div class="cp-seeWrapper">
<?php
if ( have_posts() ) :
get_search_form();//search form
?>
<div class="row">
<?php
while (have_posts()){ the_post();?>
<div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12 ">
<div class="cp-shadow cp-seeSinglePostWrapper">
<?php the_post_thumbnail();?>
<div class="bg-white single-post-box">
<div class="d-flex cp-CategoryList">
<div class="seeDate"><?php echo get_the_date('F j, Y'); ?></div>
<div class="cp_cat_list">
<?php $cat = get_the_category();?>
<a href="<?php echo esc_url( get_category_link( $cat[0]->term_id ) );?>"><?php echo $cat[0]->cat_name?></a><?php ?>
</div>
</div>
<div class="cp-b-content"><h2><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>"><?php echo wp_trim_words(get_the_title(), 12, '...'); ?></a></h2></div>
<p><?php echo wp_trim_words(get_the_excerpt(), 25, '...'); ?></p>
</div>
</div>
</div>
<?php } ?>
<?php
//the_posts_navigation();
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</div>
</div>
</div>
</main><!-- #main -->
</section><!-- #primary -->
I want to displaying only my post result but it also displaying the page. Would you help me out?
0
plugin-development, plugins, search, wordpress.org
3 years
2019-12-03T06:21:53-05:00
2019-12-03T06:21:53-05:00 0 Answers
78 views
0
Leave an answer