SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
Webinar Jan 14th, 2021
@Seravo
@ottokekalainen
Premium hosting
and upkeep for
WordPress
HTTP/2
How to extend it?
How to make it faster?
A comparison published at
ismyhostfastyet.com by Google
employees rank Seravo as the
world’s fastest WordPress hosting
service.
The study used time-to-first-byte
(TTFB) measurement data from real
users as collected from the Chrome
browser UX data.
Every content type (post, pages, media, comments etc) view
has a search box in the top right corner.
The number of results on page can be configured via Screen
Options > Number of items per page.
In any post or page, add Gutenberg block
“Search”. There are also a couple of options
to control how the search box looks like.
In Appearance > Widgets configure a
“Search” to appear in the footer or sidebar,
depending on what the selected theme
supports.
Many themes have also rolled their own
search settings.
Even if a WordPress site does not have a
search box available, one can always
manually enter ?s=keyword to run the
search.
Even though the s argument is quite
universal, Google Analytics does not support
it out-of-the-box and you need to configure it
in your Google Analytics view settings to get
search statistics.
…
…
…
…
…
wordpress/wp-includes/general-template.php
developer.wordpress.org/reference/functions/get_search_form/
developer.wordpress.org/reference/hooks/get_search_form/
developer.wordpress.org/reference/functions/get_search_link/
developer.wordpress.org/reference/functions/get_search_query/
developer.wordpress.org/reference/functions/the_search_query/
developer.wordpress.org/themes/references/list-of-template-tags/
theme/search.php:
developer.wordpress.org/themes/basics/template-hierarchy/#search-result
codex.wordpress.org/Creating_a_Search_Page
Let’s find out
1. Install Debug Bar
2. Define in wp-config:
3. Search (?s=demo)
4. View Debug > Queries
SELECT wp_posts.ID FROM wp_posts WHERE 1=1
AND (((wp_posts.post_title LIKE '%demo%') OR
(wp_posts.post_excerpt LIKE '%demo%') OR
(wp_posts.post_content LIKE '%demo%'))) AND
wp_posts.post_type IN ('post', 'page', 'attachment')
AND (wp_posts.post_status = 'publish' OR
wp_posts.post_author = 1 AND
wp_posts.post_status = 'private') ORDER BY
wp_posts.post_title LIKE '%demo%' DESC,
wp_posts.post_date DESC LIMIT 0, 10
= Title and contents of published, non-private
post, page and attachment title or contents.
Register custom post types with correct
settings, and remember to validate them by
proper testing!
developer.wordpress.org/plugins/post-types/
registering-custom-post-types/
developer.wordpress.org/reference/function
s/register_post_type/#exclude_from_search
(boolean) Whether to exclude posts with this
post type from front end search results.
Default: value of the opposite of public
argument
● ‘true’ – site/?s=search-term will not
include posts of this post type.
● ‘false’ – site/?s=search-term will
include posts of this post type.
If you have custom post types, which
typically also have custom post meta fields
and you want the search to look into them as
well – it will become pretty complicated (and
slow!).
It can however be done by hooking into
filters:
● posts_join
● posts_where
● posts_distinct
Sign up for our developer newsletter!
You’ll get notified when we publish the code
how to include meta fields in the WordPress
search in an upcoming blog post.
Due to heavy use of LIKE ‘%term%’ that
causes full table scans instead of using
database indexes.
SELECT wp_posts.ID FROM wp_posts WHERE 1=1
AND (((wp_posts.post_title LIKE '%demo%') OR
(wp_posts.post_excerpt LIKE '%demo%') OR
(wp_posts.post_content LIKE '%demo%'))) AND
wp_posts.post_type IN ('post', 'page', 'attachment')
AND (wp_posts.post_status = 'publish' OR
wp_posts.post_author = 1 AND
wp_posts.post_status = 'private') ORDER BY
wp_posts.post_title LIKE '%demo%' DESC,
wp_posts.post_date DESC LIMIT 0, 10
If the search included two terms seravo and demo:
SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%seravo%')
OR (wp_posts.post_excerpt LIKE '%seravo%') OR (wp_posts.post_content LIKE '%seravo%'))
AND ((wp_posts.post_title LIKE '%demo%') OR (wp_posts.post_excerpt LIKE '%demo%') OR
(wp_posts.post_content LIKE '%demo%'))) AND wp_posts.post_type IN ('post', 'page',
'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND
wp_posts.post_status = 'private') ORDER BY (CASE WHEN wp_posts.post_title LIKE '%seravo
demo%' THEN 1 WHEN wp_posts.post_title LIKE '%seravo%' AND wp_posts.post_title LIKE
'%demo%' THEN 2 WHEN wp_posts.post_title LIKE '%seravo%' OR wp_posts.post_title LIKE
'%demo%' THEN 3 WHEN wp_posts.post_excerpt LIKE '%seravo demo%' THEN 4 WHEN
wp_posts.post_content LIKE '%seravo demo%' THEN 5 ELSE 6 END), wp_posts.post_date DESC
LIMIT 0, 10;
The database server needs to be insanely optimized to handle these in milliseconds!
Luckily our MariaDB servers at Seravo are top notch :)
MariaDB FULLTEXT index
Easy way:
1. Install Relevanssi Light
2. Activate
For a customer with 4 GB wp_posts table
search result page load time dropped from
20 seconds to 0,2 seconds when MariaDB
FULLTEXT search was applied, and also the
relevance improved = first results were most
useful for visitors.
Hard way:
1. Learn Finnish
2. Read
wp-palvelu.fi/blogi/wordpressin-haku-
nopeaksi-mariadblla/
3. Create index via MariaDB console
4. Write a filter for posts_search in your
custom theme/plugin
Read more at: seravo.com/docs/get-started/available-commands/
Store the result of a heavy/slow computation to avoid having to do it all
the time (e.g. HTTP requests or heavy database queries):
More at: seravo.com/blog/faster-wordpress-with-transients/
and developer.wordpress.org/apis/handbook/transients/
External services can cost $$$ and €€€, in
particular for big sites that are the ones
experiencing the challenges. A custom
Elastic Search instance is easily more
expensive than a high-tier WordPress
hosting plan.
For external search to work, you need to
constantly submit all content to external
server, which adds delays and eats up server
traffic and CPU capacity.
The best solution is to have the search
in-place, in WordPress and where the data is.
Examples:
● Jetpack
● ElasticPress
● Elastic Search self-hosted or SaaS
● Algolia
● AddSearch
● Google
○ Custom search page: cse.google.com
○ Good and cheap, but has ads
@Seravo
Seravo.com @Seravo @ottokekalainen
Actually the default WordPress search looks
like this in SQL:
…
Followed by:
Why not use us COUNT(*) which is faster?
WordPress legacy reasons, just like lack of
native gettext() and why still latching on to
SVN instead of git..
Skip the use of SQL_CALC_FOUND_ROWS if you
don’t need to know the result size and don’t use
pagination:
The database is often the
performance bottleneck. See my
other talk on WordPress and
database optimization:
More in-depth code profiling tips
in my WordPress performance
talk:
wordpress.tv/?s=otto+kekäläinen
Make Your Site Faster with Caching
https://seravo.com/blog/wordpress-cache/
300% faster WordPress load times with transients
https://seravo.com/blog/faster-wordpress-with-transients/
5 common reasons why your WordPress site is slow
https://youtu.be/8sJExUO-U4A
Improving WordPress Performance with XDebug and PHP Profiling
https://youtu.be/oKcIS5A-6_c

Contenu connexe

Tendances

High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
vnsavage
 

Tendances (20)

Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)
 
Scaling WordPress
Scaling WordPressScaling WordPress
Scaling WordPress
 
Improving WordPress Performance with Xdebug and PHP Profiling
Improving WordPress Performance with Xdebug and PHP ProfilingImproving WordPress Performance with Xdebug and PHP Profiling
Improving WordPress Performance with Xdebug and PHP Profiling
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website Optimization
 
WordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress SecurityWordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress Security
 
Front-End Performance Optimizing
Front-End Performance OptimizingFront-End Performance Optimizing
Front-End Performance Optimizing
 
JS digest. Decemebr 2017
JS digest. Decemebr 2017JS digest. Decemebr 2017
JS digest. Decemebr 2017
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
 
04 web optimization
04 web optimization04 web optimization
04 web optimization
 
WPDay Bologna 2013
WPDay Bologna 2013WPDay Bologna 2013
WPDay Bologna 2013
 
Choosing a Web Architecture for Perl
Choosing a Web Architecture for PerlChoosing a Web Architecture for Perl
Choosing a Web Architecture for Perl
 
Automatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress pluginsAutomatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress plugins
 
Find WordPress performance bottlenecks with XDebug PHP profiling
Find WordPress performance bottlenecks with XDebug PHP profilingFind WordPress performance bottlenecks with XDebug PHP profiling
Find WordPress performance bottlenecks with XDebug PHP profiling
 
WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuning
 
Speed Up Wordpress, Wordpress Horsepower
Speed Up Wordpress, Wordpress HorsepowerSpeed Up Wordpress, Wordpress Horsepower
Speed Up Wordpress, Wordpress Horsepower
 
CFML Sessions For Dummies
CFML Sessions For DummiesCFML Sessions For Dummies
CFML Sessions For Dummies
 
WordPress security for everyone
WordPress security for everyoneWordPress security for everyone
WordPress security for everyone
 
DrupalCon Barcelona 2015
DrupalCon Barcelona 2015DrupalCon Barcelona 2015
DrupalCon Barcelona 2015
 

Similaire à Search in WordPress - how it works and howto customize it

WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...
Denise Williams
 
Advanced SEO for Web Developers
Advanced SEO for Web DevelopersAdvanced SEO for Web Developers
Advanced SEO for Web Developers
Nathan Buggia
 
Week 7 introduction to theme development
Week 7   introduction to theme developmentWeek 7   introduction to theme development
Week 7 introduction to theme development
henri_makembe
 

Similaire à Search in WordPress - how it works and howto customize it (20)

Extending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHPExtending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHP
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
WordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media InstituteWordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media Institute
 
Boost and SEO
Boost and SEOBoost and SEO
Boost and SEO
 
Wordpress seo and digital marketing
Wordpress seo and digital marketingWordpress seo and digital marketing
Wordpress seo and digital marketing
 
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBlog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
 
WordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute WorkshopWordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute Workshop
 
WordPress SEO in 2014 - WordCamp Baltimore 2014
WordPress SEO in 2014 - WordCamp Baltimore 2014WordPress SEO in 2014 - WordCamp Baltimore 2014
WordPress SEO in 2014 - WordCamp Baltimore 2014
 
Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10
 
WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...
 
Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency world
 
Advanced SEO for Web Developers
Advanced SEO for Web DevelopersAdvanced SEO for Web Developers
Advanced SEO for Web Developers
 
Week 7 introduction to theme development
Week 7   introduction to theme developmentWeek 7   introduction to theme development
Week 7 introduction to theme development
 
Wordpress SEO Featuring Dave Jesch
Wordpress SEO Featuring Dave JeschWordpress SEO Featuring Dave Jesch
Wordpress SEO Featuring Dave Jesch
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
WordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute WorkshopWordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute Workshop
 
How to annotate_with_wordpress
How to annotate_with_wordpressHow to annotate_with_wordpress
How to annotate_with_wordpress
 
Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08
 

Plus de Otto Kekäläinen

How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
Otto Kekäläinen
 

Plus de Otto Kekäläinen (20)

FOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
FOSDEM2021: MariaDB post-release quality assurance in Debian and UbuntuFOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
FOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
 
MariaDB quality assurance in Debian and Ubuntu
MariaDB quality assurance in Debian and UbuntuMariaDB quality assurance in Debian and Ubuntu
MariaDB quality assurance in Debian and Ubuntu
 
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
 
Technical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 editionTechnical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 edition
 
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
 
DebConf 2019 MariaDB packaging in Debian BoF
DebConf 2019 MariaDB packaging in Debian BoFDebConf 2019 MariaDB packaging in Debian BoF
DebConf 2019 MariaDB packaging in Debian BoF
 
Technical SEO for WordPress
Technical SEO for WordPressTechnical SEO for WordPress
Technical SEO for WordPress
 
WordPress-tietoturvan perusteet
WordPress-tietoturvan perusteetWordPress-tietoturvan perusteet
WordPress-tietoturvan perusteet
 
Technical SEO for WordPress - 2017 edition
Technical SEO for WordPress - 2017 editionTechnical SEO for WordPress - 2017 edition
Technical SEO for WordPress - 2017 edition
 
MariaDB adoption in Linux distributions and development environments
MariaDB adoption in Linux distributions and development environmentsMariaDB adoption in Linux distributions and development environments
MariaDB adoption in Linux distributions and development environments
 
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
 
WordPress security 101 - WP Turku Meetup 2.2.2017
WordPress security 101 - WP Turku Meetup 2.2.2017WordPress security 101 - WP Turku Meetup 2.2.2017
WordPress security 101 - WP Turku Meetup 2.2.2017
 
Testing and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressionsTesting and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressions
 
Git best practices 2016
Git best practices 2016Git best practices 2016
Git best practices 2016
 
MariaDB Developers Meetup 2016 welcome words
MariaDB Developers Meetup 2016 welcome wordsMariaDB Developers Meetup 2016 welcome words
MariaDB Developers Meetup 2016 welcome words
 
MariaDB in Debian and Ubuntu: The next million users
MariaDB in Debian and Ubuntu: The next million usersMariaDB in Debian and Ubuntu: The next million users
MariaDB in Debian and Ubuntu: The next million users
 
Koodikerho PEPE Pajapäivä 6.9.2016
Koodikerho PEPE Pajapäivä 6.9.2016Koodikerho PEPE Pajapäivä 6.9.2016
Koodikerho PEPE Pajapäivä 6.9.2016
 
MariaDB Foundation presentation and membership info
MariaDB Foundation presentation and membership infoMariaDB Foundation presentation and membership info
MariaDB Foundation presentation and membership info
 
DebConf16 BoF on MariaDB/MySQL packaging
DebConf16 BoF on MariaDB/MySQL packagingDebConf16 BoF on MariaDB/MySQL packaging
DebConf16 BoF on MariaDB/MySQL packaging
 
Less passwords, more security: unix socket authentication and other MariaDB h...
Less passwords, more security: unix socket authentication and other MariaDB h...Less passwords, more security: unix socket authentication and other MariaDB h...
Less passwords, more security: unix socket authentication and other MariaDB h...
 

Dernier

💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
nirzagarg
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
nilamkumrai
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
nirzagarg
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
nilamkumrai
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Dernier (20)

Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 

Search in WordPress - how it works and howto customize it

  • 1. Webinar Jan 14th, 2021 @Seravo @ottokekalainen
  • 2. Premium hosting and upkeep for WordPress HTTP/2
  • 3.
  • 4. How to extend it? How to make it faster?
  • 5. A comparison published at ismyhostfastyet.com by Google employees rank Seravo as the world’s fastest WordPress hosting service. The study used time-to-first-byte (TTFB) measurement data from real users as collected from the Chrome browser UX data.
  • 6. Every content type (post, pages, media, comments etc) view has a search box in the top right corner. The number of results on page can be configured via Screen Options > Number of items per page.
  • 7. In any post or page, add Gutenberg block “Search”. There are also a couple of options to control how the search box looks like. In Appearance > Widgets configure a “Search” to appear in the footer or sidebar, depending on what the selected theme supports. Many themes have also rolled their own search settings.
  • 8. Even if a WordPress site does not have a search box available, one can always manually enter ?s=keyword to run the search. Even though the s argument is quite universal, Google Analytics does not support it out-of-the-box and you need to configure it in your Google Analytics view settings to get search statistics.
  • 11.
  • 12. Let’s find out 1. Install Debug Bar 2. Define in wp-config: 3. Search (?s=demo) 4. View Debug > Queries SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%demo%') OR (wp_posts.post_excerpt LIKE '%demo%') OR (wp_posts.post_content LIKE '%demo%'))) AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_title LIKE '%demo%' DESC, wp_posts.post_date DESC LIMIT 0, 10 = Title and contents of published, non-private post, page and attachment title or contents.
  • 13. Register custom post types with correct settings, and remember to validate them by proper testing! developer.wordpress.org/plugins/post-types/ registering-custom-post-types/ developer.wordpress.org/reference/function s/register_post_type/#exclude_from_search (boolean) Whether to exclude posts with this post type from front end search results. Default: value of the opposite of public argument ● ‘true’ – site/?s=search-term will not include posts of this post type. ● ‘false’ – site/?s=search-term will include posts of this post type.
  • 14. If you have custom post types, which typically also have custom post meta fields and you want the search to look into them as well – it will become pretty complicated (and slow!). It can however be done by hooking into filters: ● posts_join ● posts_where ● posts_distinct Sign up for our developer newsletter! You’ll get notified when we publish the code how to include meta fields in the WordPress search in an upcoming blog post.
  • 15.
  • 16.
  • 17. Due to heavy use of LIKE ‘%term%’ that causes full table scans instead of using database indexes. SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%demo%') OR (wp_posts.post_excerpt LIKE '%demo%') OR (wp_posts.post_content LIKE '%demo%'))) AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_title LIKE '%demo%' DESC, wp_posts.post_date DESC LIMIT 0, 10
  • 18. If the search included two terms seravo and demo: SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%seravo%') OR (wp_posts.post_excerpt LIKE '%seravo%') OR (wp_posts.post_content LIKE '%seravo%')) AND ((wp_posts.post_title LIKE '%demo%') OR (wp_posts.post_excerpt LIKE '%demo%') OR (wp_posts.post_content LIKE '%demo%'))) AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') ORDER BY (CASE WHEN wp_posts.post_title LIKE '%seravo demo%' THEN 1 WHEN wp_posts.post_title LIKE '%seravo%' AND wp_posts.post_title LIKE '%demo%' THEN 2 WHEN wp_posts.post_title LIKE '%seravo%' OR wp_posts.post_title LIKE '%demo%' THEN 3 WHEN wp_posts.post_excerpt LIKE '%seravo demo%' THEN 4 WHEN wp_posts.post_content LIKE '%seravo demo%' THEN 5 ELSE 6 END), wp_posts.post_date DESC LIMIT 0, 10; The database server needs to be insanely optimized to handle these in milliseconds! Luckily our MariaDB servers at Seravo are top notch :)
  • 20. Easy way: 1. Install Relevanssi Light 2. Activate For a customer with 4 GB wp_posts table search result page load time dropped from 20 seconds to 0,2 seconds when MariaDB FULLTEXT search was applied, and also the relevance improved = first results were most useful for visitors. Hard way: 1. Learn Finnish 2. Read wp-palvelu.fi/blogi/wordpressin-haku- nopeaksi-mariadblla/ 3. Create index via MariaDB console 4. Write a filter for posts_search in your custom theme/plugin
  • 21. Read more at: seravo.com/docs/get-started/available-commands/
  • 22.
  • 23. Store the result of a heavy/slow computation to avoid having to do it all the time (e.g. HTTP requests or heavy database queries): More at: seravo.com/blog/faster-wordpress-with-transients/ and developer.wordpress.org/apis/handbook/transients/
  • 24.
  • 25. External services can cost $$$ and €€€, in particular for big sites that are the ones experiencing the challenges. A custom Elastic Search instance is easily more expensive than a high-tier WordPress hosting plan. For external search to work, you need to constantly submit all content to external server, which adds delays and eats up server traffic and CPU capacity. The best solution is to have the search in-place, in WordPress and where the data is. Examples: ● Jetpack ● ElasticPress ● Elastic Search self-hosted or SaaS ● Algolia ● AddSearch ● Google ○ Custom search page: cse.google.com ○ Good and cheap, but has ads
  • 26.
  • 27.
  • 30.
  • 31. Actually the default WordPress search looks like this in SQL: … Followed by: Why not use us COUNT(*) which is faster? WordPress legacy reasons, just like lack of native gettext() and why still latching on to SVN instead of git.. Skip the use of SQL_CALC_FOUND_ROWS if you don’t need to know the result size and don’t use pagination:
  • 32. The database is often the performance bottleneck. See my other talk on WordPress and database optimization: More in-depth code profiling tips in my WordPress performance talk: wordpress.tv/?s=otto+kekäläinen
  • 33. Make Your Site Faster with Caching https://seravo.com/blog/wordpress-cache/ 300% faster WordPress load times with transients https://seravo.com/blog/faster-wordpress-with-transients/ 5 common reasons why your WordPress site is slow https://youtu.be/8sJExUO-U4A Improving WordPress Performance with XDebug and PHP Profiling https://youtu.be/oKcIS5A-6_c