MakeMeHappy know-how
Praktické snippety pre WordPress a WooCommerce
Malé, vysvetlené úpravy pre konkrétne situácie. Pred použitím na produkcii ich vždy otestujte.
Introduction
When working with WordPress, the same needs appear over and over again: small behavior changes, custom conditions, text adjustments, checkout logic, pricing tweaks, or features that core WordPress or plugins simply don't offer.
That's exactly where snippets come in.
This section is built as a practical library of proven solutions - small pieces of code designed to solve one specific problem efficiently, cleanly, and without writing a full plugin.
What is a snippet?
A snippet is a small piece of code (usually PHP, CSS, or JavaScript) that:
- extends WordPress functionality,
- modifies WooCommerce behavior,
- adjusts frontend or backend output,
- or hooks into WordPress actions and filters.
A properly written snippet is not a hack.
It follows WordPress standards and behaves the same way as code inside a plugin.
What are snippets used for?
Common use cases include:
- changing button labels or system messages
- conditional checkout or cart logic
- automatic coupon generation
- pricing, tax, or shipping adjustments
- custom fields and metadata
- WooCommerce email customization
- conditional display of elements
- performance or security optimizations
Snippets are powerful because they solve exactly one problem, nothing more.
Where and how are snippets added?
1. functions.php (not recommended for production)
Quick but risky:
- lost when switching themes
- errors can break the entire site
- poor maintainability
Useful for testing, not ideal long-term.
2. Custom mini-plugin (cleanest approach)
Snippets live inside a plugin:
- theme-independent
- better structure
- scalable
Best practice, but sometimes overkill for small tweaks.
3. Snippet manager plugins (best balance)
Snippet plugins allow you to manage custom code safely from the admin panel:
- enable / disable snippets instantly
- prevent fatal errors
- keep everything organized
- no direct file editing
Popular solutions include:
- Fluent Snippets
- Code Snippets
- WPCode Box
Using these tools significantly reduces the risk and speeds up development.
What to expect in this section?
Snippets published on makemehappy.sk are:
- focused on real-world problems
- tested in production projects
- written clearly and extensibly
- often commented and explained
Some are simple, others more advanced - but always practical.
Who is this for?
- WordPress administrator
- WooCommerce store owners
- developers and freelancers
- technical users who want control
If you understand hooks, filters, or at least functions.php, you'll feel at home here.
Final thoughts
Snippets are one of the most efficient ways to shape WordPress exactly to your needs - without bloated plugins, without compromises, and without messy codebases.
This section aims to become a reliable go-to resource you'll come back to whenever you need a clean solution.
Knižnica riešení
Najnovšie snippety
How to display the weight of a product anywhere using a shortcode
Sometimes you need to display a product's weight right next to the price, in the description, or in a special block—and not just in the default parameters table. WooCommerce offers this option in…
Čítať ďalejForm to repeat an order via shortcode
Sometimes a customer doesn't need to browse the entire catalog to buy the same thing they bought last time. All they need is their previous order number and email address. This snippet creates a simple…
Čítať ďalejHow to change the logo on the WordPress login page
The default WordPress logo on the login screen (wp-login.php) is fine, but if you're building a website for a client or want to strengthen your own brand, replacing it with your own…
Čítať ďalejDynamic order button with total amount display
This handy snippet customizes the text of the main button on your e-shop’s checkout page. Instead of the standard „Place Order with Payment“ or „Submit Order,“ it adds the following text…
Čítať ďalejAdding an attachment to an email after an order in WooCommerce
This snippet allows you to automatically add an attachment to WooCommerce emails after an order is created or completed. It is most commonly used to send documents such as General Terms and Conditions…
Čítať ďalejHow to Set Mobile Status Bar Color on Android and iOS in WordPress
This snippet sets the color of the top system status bar on mobile devices. On Android, it changes the color of the browser's status bar using the `theme-color` meta tag.…
Čítať ďalej


