WordPress’te bir arama geçiş efekti eklemek ister misiniz?
Arama geçiş efekti, form yerine bir arama simgesi görüntülemenizi sağlar. Simgeye tıklandığında, arama formu ince bir kayma animasyonuyla görüntülenir.
Bu makalede, WordPress’te arama geçiş efektini nasıl kolayca ekleyebileceğinizi göstereceğiz.
WordPress’te Arama Geçiş Efekti Nedir?
Arama geçiş efekti, bir WordPress web sitesinde arama deneyimini iyileştirmek için kullanılan bir web tasarım tekniğidir.
Bir arama formu görüntülemek yerine, bir arama simgesi görüntüleyeceksiniz. Bir kullanıcı bu simgeye tıkladığında, arama formu bir kayma animasyonuyla birlikte görünür.
Varsayılan WordPress arama formu pek iyi görünmüyor. Birçok üst düzey WordPress teması zaten varsayılan formu kendi stilleriyle değiştiriyor.
Bununla birlikte, temanız hala statik, düz bir arama formu kullanıyorsa, daha kullanıcı dostu hale getirmek için bu öğreticiyi kullanabilirsiniz.
Bununla birlikte, WordPress’te arama geçiş efektinin nasıl kolayca ekleneceğine bakalım.
Not: Bu eğitim orta ve ileri düzey kullanıcılar içindir çünkü HTML/CSS hakkında temel bilgi sahibi olmayı gerektirir.
WordPress’te Arama Geçiş Efekti Ekleme
WordPress’te bir arama geçiş efekti eklemek için web sitenize bir arama formu bloğu veya widget’ı yerleştirmeniz ve ardından bazı özel CSS kodları eklemeniz gerekir.
Öncelikle, web sitenize bir arama formu eklendiğinden emin olmanız gerekir.
Tam Site Düzenlemesi ile Blok Temaya Arama Formu Ekleme
Tam site düzenleme özelliğine sahip daha yeni bir WordPress blok teması kullanıyorsanız, arama formunu web sitenize bu şekilde ekleyeceksiniz.
Basitçe Görünüm ” Düzenleyici sayfasını ziyaret edin. Düzenleme ekranında, arama formunu görüntülemek istediğiniz yere ‘Arama’ bloğunu ekleyin.
Bundan sonra, değişikliklerinizi kaydetmek için ‘Kaydet’ düğmesine tıklamayı unutmayın.
Diğer WordPress Temalarına Arama Formu Ekleme
Tam site düzenleme özelliği olmayan WordPress temaları için, arama bloğunu veya widget’ını kenar çubuğunuza veya widget’a hazır herhangi bir alana ekleyebilirsiniz.
Görünüm ” Widget ‘lar sayfasına gidin ve arama formunu görüntülemek istediğiniz kenar çubuğuna ‘Arama’ bloğunu/widget’ını ekleyin.
Ardından, arama simgesi için şeffaf bir görüntü bulmanız gerekir.
Bu eğitim için bu görseli kullanacağız. Koyu arka planlar için uygundur (web sitenizde kullanmaktan çekinmeyin).
Kendi arama simgenizi yapmanız gerekiyorsa, boyutları 50×50 pikselden fazla olmayan şeffaf bir PNG görüntüsü oluşturmanız harika olur.
Resim simgesine sahip olduğunuzda, bunu web sitenize yüklemeniz gerekir. Medya ” Yeni Ekle sayfasına gidin ve arama simgesi resminizi yükleyin.
Yüklendikten sonra, ‘URL’yi panoya kopyala’ düğmesine tıklayın ve ardından bu URL’yi Notepad veya TextEdit gibi bir düz metin düzenleyicisine yapıştırın.
Artık her şey yerli yerinde olduğuna göre, WordPress web sitenize bazı özel CSS’ler eklemeniz gerekir.
Bu eğitimin amacı doğrultusunda, özel CSS’nizi kaydetmek için WPCode eklentisini kullanmanızı öneririz.
WPCode, WordPress‘e kolayca özel kod parçacıkları eklemenizi sağlar. Kullanımı kolaydır ve kodunuz tema güncellemelerinden veya farklı bir temaya geçtiğinizde etkilenmez.
Öncelikle, ücretsiz WPCode eklentisini yüklemeniz ve etkinleştirmeniz gerekir. Daha fazla ayrıntı için, WordPress eklentisinin nasıl kurulacağına ilişkin adım adım kılavuzumuza bakın.
Etkinleştirmenin ardından, WordPress yönetici panonuzdaki Kod Parçacıkları sayfasını ziyaret etmeniz gerekir. Ardından, üstteki ‘Yeni Ekle’ düğmesine tıklamanız yeterlidir.
Bir sonraki ekranda, öncelikle bu kod parçacığı için bir başlık sağlamanız gerekir. Bu kod parçacığını tanımlamanıza yardımcı olacak herhangi bir şey olabilir.
Bundan sonra, ‘Kod Türü’nü ‘HTML Snippet’ olarak değiştirin. Özel CSS’mizi HTML kullanarak web sitesi başlığına yükleyeceğiz.
Şimdi, aşağıdaki kodu ‘Kod Önizleme’ kutusuna yapıştırmanız gerekir.
<style type="text/css">
.wp-block-search__inside-wrapper
.wp-block-search__input {
background-color: transparent;
background-image: url(/url/to/search-icon.png);
background-position: 5px center;
background-repeat: no-repeat;
background-size: 24px 24px;
border: none;
cursor: pointer;
height: 37px;
margin: 3px 0;
padding: 0 0 0 34px;
position: relative;
-webkit-transition: width 400ms ease, background 400ms ease;
transition: width 400ms ease, background 400ms ease;
width: 0;
}
.wp-block-search__inside-wrapper
.wp-block-search__input:focus {
background-color: #fff;
border: 2px solid #c3c0ab;
cursor: text;
outline: 0;
width: 230px;
}
.search-form
.search-submit {
display:none;
}
</style>
Önemli: /url/to/search-icon.png
yerine daha önce kopyaladığınız resim URL’sini koymayı unutmayın.
Bundan sonra, Etkin Değil geçişini ‘Etkin’ olarak değiştirmeniz ve ardından ‘Snippet’i Kaydet’ düğmesine tıklamanız gerekir.
Artık web sitenizi ziyaret ederek geçiş efektli arama formunuzu çalışırken görebilirsiniz.
Arama Formu Geçiş Etkisi Sorunlarını Giderme
Yukarıdaki yöntem, widget blokları kullanan çoğu modern WordPress temasıyla çalışacaktır.
Ancak bazı temalar için bu yöntem işe yaramayabilir.
WordPress temanızdaki arama formu wp-block-search__inside-wrapper
ve wp-block-search__input
sınıflarına sahip değilse bu durum meydana gelebilir.
Bu durumda, WordPress temanız tarafından hangi CSS sınıflarının kullanıldığını bulmak için denetleme aracını kullanmanız gerekecektir.
Örneğin, aşağıdaki ekran görüntüsünde, demo temamız arama formu için bu CSS sınıflarını kullanmaktadır.
Şimdi, aşağıdaki kodu değiştirebilir ve bunun yerine bu CSS sınıflarını kullanabilirsiniz. İşte bir örnek.
<style type="text/css">
.search-wrap input.s {
background-color: transparent;
background-image: url(/url/to/search-icon.png);
background-position: 5px center;
background-repeat: no-repeat;
background-size: 24px 24px;
border: none;
cursor: pointer;
height: 37px;
margin: 3px 0;
padding: 0 0 0 34px;
position: relative;
-webkit-transition: width 400ms ease, background 400ms ease;
transition: width 400ms ease, background 400ms ease;
width: 0;
}
.search-wrap input.s:focus {
background-color: #fff;
border: 2px solid #c3c0ab;
cursor: text;
outline: 0;
width: 230px;
}
.search-form
.search-submit {
display:none;
}
</style>
İşte test web sitemizde nasıl göründüğü.
Bonus İpucu: Web Siteniz İçin Daha İyi Bir WordPress Araması Ekleyin
Geçiş efekti yalnızca WordPress arama formunuzun güzel görünmesini sağlar. Web sitenizdeki arama sonuçlarının kalitesini etkilemez.
WordPress varsayılan olarak çok temel bir arama özelliği ile birlikte gelir. Bu arama özelliği yavaş, hatalı ve genellikle boş sonuçlar gösteriyor.
İşte SearchWP burada devreye giriyor.
Piyasadaki en iyi WordPress arama eklentisidir ve varsayılan arama özelliğini güçlü bir arama motoruyla kolayca değiştirmenize olanak tanır.
SearchWP arama formlarını otomatik olarak değiştirir, böylece herhangi bir tema dosyasını düzenlemenize gerek kalmaz. Web sitenizin her yerinde eşleşmeleri arar ve arama sonuçlarının kalitesini büyük ölçüde artırır.
Ayrıca, kullanıcılar sorgularını yazarken sonuçları anında görüntülemek için bir canlı arama uzantısı ile birlikte gelir. Ayrıca, çevrimiçi mağazanızda akıllı bir WooCommerce arama deneyimi oluşturmanıza olanak tanıyan tam e-ticaret desteğine sahiptir.
Umarız bu makale WordPress’te arama geçiş efektinin nasıl ekleneceğini öğrenmenize yardımcı olmuştur. Ayrıca WordPress dönüşüm izleme kılavuzumuzu görmek veya sitenizdeki en popüler gönderileri nasıl bulacağınızı öğrenmek isteyebilirsiniz.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
James Burns says
Thank you so much. Exactly the info I needed, presented in an easy-to-understand format.
WPBeginner Support says
You’re welcome, glad you found our content helpful
Yönetici
Osh says
Hi,
I’m using a child theme, should i add those codes to the parent theme’s files?
I tried to do that and it is not working, please help !!!
Thanks
WPBeginner Support says
You would want to add the code to your child theme
Yönetici
Benjamin Rutledge says
Is it possible to implement this only on mobile? My theme has a nice animated search function on desktop, but only a toggle to show/hide search box in place of my logo on mobile.
Beth Terry says
Hi. Thank you very much for this code. I did have to play around with the positioning to get the search button to appear where I want it, and since I only wanted it to appear in the mobile version, I also added css to the media query for over 800px screens to show the full search field instead of the icon. I got it working great, but I do think it’s a little complicated for folks who just want something to basically plug and play.
You can view the results here:
To everyone who doubts, javascript is definitely not needed.
Beth Terry says
Also, I want to add that I am using a Twenty Twelve child theme, which comes with the HTML4 search code. Adding the HTML5 support to the functions.php did not fix it, so I copied and pasted the HTML5 search code that you posted above into my theme header where I wanted to search box to be.
Emily G says
Hi there – implementing this on a website and would like to use FontAwesome instead of an image. I cannot get the icon to show yup, however. Do you have any tips? I am adding the font and icon font-family: FontAwesome;
content: “\f002″; to the .search-form input[type=”search”]
Thanks!
Bradley says
Try this:
font: normal normal normal 1em/1 FontAwesome;
Steve says
I was so hoping this would work for me. I pasted in the code in the Additional CSS area of my theme (twentytwelvechild), added the search-icon.png to my theme folder using FTM and added add_theme_support(‘html5’, array(‘search-form’)); to my theme’s functions.php file. I see no change and wonder what I have missed. I hope someone can offer me a clue. thank you.
Harmandeep Singh says
Its not working.
Crowd says
Thank you very much, works like a charm.
Do you think there’s a way to make the search field appear from right to left (unlike from left to right like now)?
Marimar says
Align the text to the right
text-align: right;
It slides to the other side.
Tony López says
Thanks! It work perfectly.
Cato says
Yeah… just like I thought, this doesn´t work at all. How is it supossed to work with no JS anyway?
Cato says
Hmmm this is kind of old but… no javascript required here really? what kind of dark magic is this?
WPBeginner Support says
Instead of JS, this technique uses CSS.
Yönetici
SiRetu says
Thanks for the code… Is this responsive? I mean, I want the search field is fully showed when in mobile. Is it possible?
Panfi says
Not working for me and wonder why
Cassy says
I got this working on genesis but my search form is in my nav bar, and when the screen width is relatively too small, the search form moves down.
Sohan says
It works!
Thank you soooooooooooooo much!
Anur says
I dont think this works on Genesis
Cassy says
I got it working on Genesis. You have to move the search-icon.png into your genesis child theme images folder. Then, depending on where you put your search form, mine is in the nav bar so it is slightly different, you adjust the css style to your likes. I had to modify the “.genesis-nav-menu .search input” class to get it working.
Laura says
Hi Cassy, Can you give a little more info on how you modified the .genesis-nav-menu .search input class? I can’t seem to get it working. Thanks!
Maria says
Hi! I’m using Genesis and I can’t get this effect to work. Any tips as to why?
Anur says
yea the same problem im on genesis with enteprise pro theme doesnt work.
Anyone who has solution to make this work on genesis..
Roy says
this is really great! Is it possible to get the icon to sit static at the right while the form slides out to the left? I can’t seem to figure it out!
Joshua Farr says
Greetings – Thank you for this great bit of code. I’ve tried inserting it into a client’s site that I’m working, using the HTML5 version of the code, I placed the extra bit into functions.php and added all of the css. I put in a search icon and got the form to show up how I want on the site – it will even do all of the toggle-ing effect as desired – but when I enter text that I want to search to test it out, I can not submit the search to view search results. We are using a woocommerce theme, “Mystile”, which has a default search form (which works when entered) but I much prefer the looks and functionality of the form as mentioned on this page.
We tried putting the wocommerce search form code side by side with the code you gave above, tried swapping out bits and pieces to “merge” the two…but no luck.
Any reccomendations would be extremely helpful.
Thank you!
-Josh
WPBeginner Support says
There could be many things that may cause this, it is not possible for us to help out with theme compatibility issues.
Yönetici
Rajeesh Nair says
Now that’s some interesting stuff there. Though I am a mere beginner and I actually use the search option that has come default with the blog theme which is like a pop-up (not exactly a pop-up though as its CSS and not javascript) and displays search bar.
But what I am exactly looking for is that how to display Google Search along with Blog search as found in popular blogs like ListVerse and others. Please guide me through this!
WPBeginner Support says
Take a look at our guide on how to add Google search in WordPress.
Yönetici
adolf witzeling says
Another great tutorial. I will add this to my site-just because it’s cool.
alexisnicholson says
Code looks fabulous , I appreciate your efforts , surely gonna try this one for my word press project .
Codingbrains
Shahraar Khan says
A demo would be helpful.. Also what does the use of role=”search” attribute in the form tag, what is the attribute “role” used for?
Susan Silver says
I have been looking for a simple tutorial on this. Thanks! Have you done one yet on the sliding menus like those on the Facebook mobile app? These menus are becoming very popular, even for desktop apps.
WPBeginner Support says
Actually we have, checkout how to add a slide panel menu in WordPress.
Yönetici