Created
August 19, 2015 20:00
-
-
Save jgrossi/6f02dbd058558f9db61b to your computer and use it in GitHub Desktop.
How to make a search with Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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() ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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