際際滷

際際滷Share a Scribd company logo
Mastering the Art of
WordPress: 13 Years of
Advanced Tips and Tricks
Stanko Metodiev
WordCamp So鍖a, 2024
Stanko Metodiev
About Stanko
 CTO @ DevriX
 WordPress Core and community contributor
 (Co) Leader of the 鍖rst WordPress meetup in
Bulgaria - WordPress So鍖a (WPBGUG)
 WordCamp Organizer and Lead Organizer of
WordCamp So鍖a 2023
 More than 13 years in developing complex
SaaS platforms and multisite solutions
 Proud dad and a husband of princesses
Table of
Contents
 A little bit of a backstory
 Some code snippets here and there
 Some WordPress tips and tricks
 Some tools
 Some personal thoughts and my journey so
far
 And I hope you'll learn something new today
The personal growth
From simply the blog owner to becoming a CTO
The personal growth
 Started university as both a joke and an experiment
Stanko Metodiev
The personal growth
 Started university as both a joke and an experiment
 Met some amazing people and made connections
Stanko Metodiev
The personal growth
 Started university as both a joke and an experiment
 Met some amazing people and made connections
 Demonstrated organizational skills
Stanko Metodiev
The personal growth
 Started university as both a joke and an experiment
 Met some amazing people and made connections
 Demonstrated organizational skills
 Wasn't the best student :D (not an actual advice)
Stanko Metodiev
The personal growth
 Started university as both a joke and an experiment
 Met some amazing people and made connections
 Demonstrated organizational skills
 Wasn't the best student :D (not an actual advice)
 Started as an intern
Stanko Metodiev
The personal growth
 Started university as both a joke and an experiment
 Met some amazing people and made connections
 Demonstrated organizational skills
 Wasn't the best student :D (not an actual advice)
 Started as an intern
 Worked hard and learned daily
Stanko Metodiev
The personal growth
 Started university as both a joke and an experiment
 Met some amazing people and made connections
 Demonstrated organizational skills
 Wasn't the best student :D (not an actual advice)
 Started as an intern
 Worked hard and learned daily
 Made mistakes and improved by doing them
Stanko Metodiev
The personal growth
 Started university as both a joke and an experiment
 Met some amazing people and made connections
 Demonstrated organizational skills
 Wasn't the best student :D (not an actual advice)
 Started as an intern
 Worked hard and learned daily
 Made mistakes and improved by doing them
 Didn't give up Stanko Metodiev
Beyond the Code:
Professional Growth Path
Open Source Community
 Build and share
 Write (technical)
articles and share
knowledge
 Mentor others
 Contribute to
WordPress and
Open-Source
 Speak at
WordCamps and
conferences
 Organize local
meetups
Technical Excellence
 Master your craft
 Technical expertise
 Balance perfection
with pragmatism
 Strategic thinking
 Learning routine
 Time management
 Develop leadership
skills
 Write maintainable,
scalable code
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Lets get some (actual) advice,
shall we?
Stanko Metodiev
wp_enqueue* and Asset
Optimizations
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
The query_posts() trap
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
 Performance impact - replaces the primary query, query_posts results in
two queriesone for the original and one for the overrideleading to
unnecessary database load
 Risk of unexpected behavior - accidentally alter the main query in ways
that interfere with themes and plugins expecting the default query
structure, causing compatibility issues
 Limited control: unlike pre_get_posts, query_posts doesnt allow
developers to refine or manipulate the existing query
 Best practice: WordPress recommends using pre_get_posts or custom
WP_Query instances for safe and effective query modifications
Why NOT query_posts()?
Stanko Metodiev
pre_get_posts()
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Why pre_get_posts()?
Stanko Metodiev
 Improves performance
 Reduce unnecessary queries
 Increased efficiency - load only relevant data, improving page speed
 Tailor query results
 Its just nice tool to have
 There are other pre_get_<something>, check them out
get_posts()
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Why and when to use get_posts()?
Stanko Metodiev
 Best for simple queries
 When you need just the post data
 Better performance with small queries
 Simple syntax
 Always use wp_reset_postdata() after custom queries
WP_Query()
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Why and when to use WP_Query()?
Stanko Metodiev
 Full control over queries
 Built-in compatibility
 Flexible data retrieval
 Enhanced performance options
 Pagination support
 And many more
 Always use wp_reset_postdata() after custom queries
Query optimizations
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Why you should be careful with -1?
Stanko Metodiev
 Retrieve all posts without limitation
 Avoids pagination
 Useful for non-public data *
Caution: be mindful when using -1 on high-traffic,
public-facing pages with a large dataset, as it can impact
performance.
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
WP_Query optimizations
Stanko Metodiev
 use posts_per_page
 use post_status when applicable
 use no_found_rows when you dont need pagination
 use update_post_meta_cache argument if you dont need meta data
 use update_post_term_cache argument when do dont need taxonomy
 use fields when you need just IDs*
Object Cache is your friend
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Why and when to use Object Cache?
Stanko Metodiev
 Improves performance - reduces the number of expensive database
queries
 Scales better with high traffic - caching frequently requested data
prevents database overload during peak traffic
 Increases user experience - faster response times improve the user
experience
 Flexible expiration
Transients are your friends
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
 transients cache expensive data (e.g., API responses) to prevent
repetitive processing
 Reduces server load
 Efficient caching control and Ideal for temporary Data
 Flexible storage - transients can be stored in the database or in-memory
using object caching systems like Redis or Memcached
 Better user experience - faster load times improve the user experience
Why and when to use Transients?
Stanko Metodiev
REST API to the rescue
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
Why and when to use REST API?
Stanko Metodiev
 In our example:
 Building social media cards or creating preview widgets
 Creating link previews in headless WordPress setups
 Getting optimized post data for mobile apps
 Headless applications
 Data hub applications
 3rd party integrations
 Many, many more
What about security?
Stanko Metodiev
Security 101
Stanko Metodiev
 Use strong and unique passwords. Full stop.
 Use 2FA/Passkeys
 Regular users audit
 Limited login attempts
 Solid hosting provider
 Regular updates
 Do not rely on security plugins *
 Never ever nulled themes/plugins
Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks
be careful with the items youll use here
What about some tools?
Stanko Metodiev
 Personalized Text Editor/IDE
 Shortcuts and alias
 Trusted plugins
 Templates for anything
 Code snippets, libraries, and templates
 Bash/SSH/Terminal
 WP-CLI and Query Monitor
 Chrome dev tools *
 Git/Version Control
Tools
Stanko Metodiev
AI Tools
 ChatGPT / Claude / Gemini
 AI changes the way we work
 AI can be your friend if you
 know how to use it
 AI website / WordPress builders
 Make sure to check some of the AI-related talks today!
Stanko Metodiev
Thank you!
Get in
Touch
@metodiew
Twitter
metodiew
WordPress.org metodiew.com
Stanko Metodiev
LinkedIn
Stanko Metodiev

More Related Content

Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks

  • 1. Mastering the Art of WordPress: 13 Years of Advanced Tips and Tricks Stanko Metodiev WordCamp So鍖a, 2024
  • 2. Stanko Metodiev About Stanko CTO @ DevriX WordPress Core and community contributor (Co) Leader of the 鍖rst WordPress meetup in Bulgaria - WordPress So鍖a (WPBGUG) WordCamp Organizer and Lead Organizer of WordCamp So鍖a 2023 More than 13 years in developing complex SaaS platforms and multisite solutions Proud dad and a husband of princesses
  • 3. Table of Contents A little bit of a backstory Some code snippets here and there Some WordPress tips and tricks Some tools Some personal thoughts and my journey so far And I hope you'll learn something new today
  • 4. The personal growth From simply the blog owner to becoming a CTO
  • 5. The personal growth Started university as both a joke and an experiment Stanko Metodiev
  • 6. The personal growth Started university as both a joke and an experiment Met some amazing people and made connections Stanko Metodiev
  • 7. The personal growth Started university as both a joke and an experiment Met some amazing people and made connections Demonstrated organizational skills Stanko Metodiev
  • 8. The personal growth Started university as both a joke and an experiment Met some amazing people and made connections Demonstrated organizational skills Wasn't the best student :D (not an actual advice) Stanko Metodiev
  • 9. The personal growth Started university as both a joke and an experiment Met some amazing people and made connections Demonstrated organizational skills Wasn't the best student :D (not an actual advice) Started as an intern Stanko Metodiev
  • 10. The personal growth Started university as both a joke and an experiment Met some amazing people and made connections Demonstrated organizational skills Wasn't the best student :D (not an actual advice) Started as an intern Worked hard and learned daily Stanko Metodiev
  • 11. The personal growth Started university as both a joke and an experiment Met some amazing people and made connections Demonstrated organizational skills Wasn't the best student :D (not an actual advice) Started as an intern Worked hard and learned daily Made mistakes and improved by doing them Stanko Metodiev
  • 12. The personal growth Started university as both a joke and an experiment Met some amazing people and made connections Demonstrated organizational skills Wasn't the best student :D (not an actual advice) Started as an intern Worked hard and learned daily Made mistakes and improved by doing them Didn't give up Stanko Metodiev
  • 14. Open Source Community Build and share Write (technical) articles and share knowledge Mentor others Contribute to WordPress and Open-Source Speak at WordCamps and conferences Organize local meetups
  • 15. Technical Excellence Master your craft Technical expertise Balance perfection with pragmatism Strategic thinking Learning routine Time management Develop leadership skills Write maintainable, scalable code
  • 17. Lets get some (actual) advice, shall we? Stanko Metodiev
  • 23. Performance impact - replaces the primary query, query_posts results in two queriesone for the original and one for the overrideleading to unnecessary database load Risk of unexpected behavior - accidentally alter the main query in ways that interfere with themes and plugins expecting the default query structure, causing compatibility issues Limited control: unlike pre_get_posts, query_posts doesnt allow developers to refine or manipulate the existing query Best practice: WordPress recommends using pre_get_posts or custom WP_Query instances for safe and effective query modifications Why NOT query_posts()? Stanko Metodiev
  • 26. Why pre_get_posts()? Stanko Metodiev Improves performance Reduce unnecessary queries Increased efficiency - load only relevant data, improving page speed Tailor query results Its just nice tool to have There are other pre_get_<something>, check them out
  • 29. Why and when to use get_posts()? Stanko Metodiev Best for simple queries When you need just the post data Better performance with small queries Simple syntax Always use wp_reset_postdata() after custom queries
  • 32. Why and when to use WP_Query()? Stanko Metodiev Full control over queries Built-in compatibility Flexible data retrieval Enhanced performance options Pagination support And many more Always use wp_reset_postdata() after custom queries
  • 36. Why you should be careful with -1? Stanko Metodiev Retrieve all posts without limitation Avoids pagination Useful for non-public data * Caution: be mindful when using -1 on high-traffic, public-facing pages with a large dataset, as it can impact performance.
  • 38. WP_Query optimizations Stanko Metodiev use posts_per_page use post_status when applicable use no_found_rows when you dont need pagination use update_post_meta_cache argument if you dont need meta data use update_post_term_cache argument when do dont need taxonomy use fields when you need just IDs*
  • 39. Object Cache is your friend
  • 42. Why and when to use Object Cache? Stanko Metodiev Improves performance - reduces the number of expensive database queries Scales better with high traffic - caching frequently requested data prevents database overload during peak traffic Increases user experience - faster response times improve the user experience Flexible expiration
  • 47. transients cache expensive data (e.g., API responses) to prevent repetitive processing Reduces server load Efficient caching control and Ideal for temporary Data Flexible storage - transients can be stored in the database or in-memory using object caching systems like Redis or Memcached Better user experience - faster load times improve the user experience Why and when to use Transients? Stanko Metodiev
  • 48. REST API to the rescue
  • 52. Why and when to use REST API? Stanko Metodiev In our example: Building social media cards or creating preview widgets Creating link previews in headless WordPress setups Getting optimized post data for mobile apps Headless applications Data hub applications 3rd party integrations Many, many more
  • 54. Security 101 Stanko Metodiev Use strong and unique passwords. Full stop. Use 2FA/Passkeys Regular users audit Limited login attempts Solid hosting provider Regular updates Do not rely on security plugins * Never ever nulled themes/plugins
  • 56. be careful with the items youll use here
  • 57. What about some tools? Stanko Metodiev
  • 58. Personalized Text Editor/IDE Shortcuts and alias Trusted plugins Templates for anything Code snippets, libraries, and templates Bash/SSH/Terminal WP-CLI and Query Monitor Chrome dev tools * Git/Version Control Tools Stanko Metodiev
  • 59. AI Tools ChatGPT / Claude / Gemini AI changes the way we work AI can be your friend if you know how to use it AI website / WordPress builders Make sure to check some of the AI-related talks today! Stanko Metodiev