Skip to content

Instantly share code, notes, and snippets.

@jgrossi
Created August 19, 2015 20:00
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 jgrossi/6f02dbd058558f9db61b to your computer and use it in GitHub Desktop.
Save jgrossi/6f02dbd058558f9db61b to your computer and use it in GitHub Desktop.
How to make a search with Wordpress
<?php // File wherer you include the form to make a search ?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div class="header">
<div class="container">
<div class="logo"></div>
<ul class="menu"></ul>
<div class="search">
<?php get_search_form() ?>
<?php // Use this to get the form (searchform.php file on theme's folder) ?>
</div>
</div>
</div>
<?php // File where you show all search results ?>
<?php get_header() ?>
<div class="search">
<h1></h1>
<h2></h1>
<?php while (have_posts()) : the_post() ?>
<div class="result">
<h3><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h3>
<a href="<?php the_permalink() ?>">
<?php the_content() ?>
</a>
</div>
<?php endwhile; ?>
</div>
<?php get_footer() ?>
<?php // File where you the the form to make the search ?>
<form method="get" id="searchform" action="<?php echo home_url('/') ?>">
<input type="text" placeholder="Search..." name="s" id="query" />
<input type="submit" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment