Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn to Create WordPress Themes by Building 5 Projects

You're reading from   Learn to Create WordPress Themes by Building 5 Projects Master the fundamentals of WordPress theme development and create attractive WordPress themes from scratch

Arrow left icon
Product type Paperback
Published in Dec 2017
Publisher Packt
ISBN-13 9781787286641
Length 458 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Eduonix Learning Solutions Eduonix Learning Solutions
Author Profile Icon Eduonix Learning Solutions
Eduonix Learning Solutions
Arrow right icon
View More author details
Toc

Adding a search bar and single post page

So let's get started.

Dealing with the search box

Go to our header file and go to the empty form down at the bottom of the file, and we will add some stuff to it. The first thing we'll do is adding a method and the method is going to be get. We can actually change the class from left to right. We also need to add an action. For that, we will use the php tags and add echo esc_url().

This is because we want the URL checked and escaped. We will use home_url with a /:

<form method="get" class="navbar-form navbar-right" 
role="search" action="<?php echo esc_url(home_url('/')); ?>">

Basically, we're just submitting...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime