Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@humayunahmed8
Last active December 8, 2017 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save humayunahmed8/fdde9dd849c306abbee929c3262621d6 to your computer and use it in GitHub Desktop.
Save humayunahmed8/fdde9dd849c306abbee929c3262621d6 to your computer and use it in GitHub Desktop.
Dynamic Searchbar
// Dynamic search bar (searchform.php).
<!-- Search Bar -->
<div class="widget blog-search-bar">
<h4 class="title">Search</h4>
<form class="form-search" method="get" id="s" action="<?php bloginfo('url'); ?>/">
<div class="input-append">
<input class="form-control input-medium search-query" type="text" name="s" value="<?php the_search_query(); ?>" placeholder="Search" required>
<button class="add-on" type="submit"><i class="fa fa-search"></i></button>
</div><!-- /.input-append -->
</form><!-- /.form-search -->
</div><!-- /.blog-search-bar -->
<!-- Search Bar End -->
// The template for displaying search results pages (search.php).
<div class="blog-content">
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="post-container">
<h2><?php echo 'search for: ' . get_search_query(); ?></h2>
<?php
if(have_posts()) : while(have_posts()) : the_post();
?>
<div class="single-post">
<p class="entry-date"><?php the_time('F j,Y');?></p>
<a href="<?php the_permalink();?>" class="entry-title"><?php the_title();?></a>
<span class="auther">Posted By: <a href="<?php the_author_link();?>"><?php the_author();?></a></span>
<p class="entry-comtent"><?php echo wp_trim_words(get_the_content(),40);?><a href="<?php the_permalink();?>" class="more-link">Read More...</a></p>
</div><!-- /.single-post -->
<hr>
<?php endwhile; endif;?>
</div> <!-- /.post-container -->
<!-- pagination -->
<?php if (function_exists("pagination")) {pagination();} ?>
</div> <!-- /.col-md-8 -->
<!-- call right sidebar -->
<?php get_sidebar(); ?>
</div>
</div> <!-- /.container -->
</div> <!-- /.blog-content -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment