WordPress Development
WordPress Theme Customisation Without Plugins: functions.php Recipes
Many WordPress customisations need no plugin — just a few lines in your child theme functions.php. Here are the most useful recipes for common customisation tasks.
Simple Automation Solutions
··⌛ 9 min read
Most WordPress customisation guides default to recommending a plugin for every task. But many common customisation needs — removing the blog page, adding custom CSS to specific pages, displaying different content per user role, or adding a custom header element — can be accomplished cleanly with a few lines of PHP in your child theme functions.php, without installing a plugin that adds unnecessary overhead.
Why code in functions.php beats plugins for simple customisations
Every plugin you install adds: at least one PHP file loaded on every WordPress request, potential conflicts with other plugins, a maintenance burden when updates break things, and an attack surface for security vulnerabilities. For simple customisations that require 5-20 lines of PHP, a child theme functions.php entry is faster, lighter, and more maintainable.
- Performance: a single function in functions.php has essentially zero overhead. A plugin adds autoloading, activation checks, and database queries on every request.
- Maintainability: all your site customisations in one file are easier to audit and document than scattered across 10 plugin settings screens.
- No dependency risk: plugins get abandoned, change pricing, or become incompatible. Your own functions.php code is fully under your control.
Never add code to a parent theme’s functions.php. When the parent theme updates, your customisations are overwritten. A child theme functions.php survives all parent theme updates.
Removing unwanted WordPress features
Remove the WordPress admin bar for non-admins
The admin bar appears for all logged-in users. For subscriber or customer accounts on membership or WooCommerce sites, remove it: add_filter('show_admin_bar', '__return_false'); for all users, or wrap in a current_user_can check to remove it only for specific roles.
Remove the blog / posts page
Sites that use WordPress as a CMS without a blog can hide the Posts menu from the admin: use the show_admin_bar approach or remove the Posts menu with remove_menu_page('edit.php'); in an admin_menu hook. Remove the blog from public URLs by ensuring your front page is set to a static page in Settings › Reading.
Remove default dashboard widgets
Clean up the admin dashboard for clients by removing unwanted widgets: hook wp_dashboard_setup and use remove_meta_box() for each widget you want to remove (welcome panel, quick draft, WordPress news, etc.).
Adding custom content and elements
Add content before or after every post
Filter the_content to add content before or after every post. Use is_single(), is_page(), or get_post_type() checks to limit application to specific content types. Return the modified $content.
Add a custom class to body based on conditions
Filter body_class to add custom CSS classes to the body element based on any condition: logged-in user, post category, page template, or custom field value. This enables pure-CSS conditional styling without JavaScript.
Add custom HTML to the head on specific pages
Hook wp_head with a conditional check to add custom meta tags, tracking scripts, or structured data only on specific pages. More targeted than adding code to every page via a plugin.
Modifying navigation and menus
Add a log in / log out link to menus dynamically
Filter wp_nav_menu_items to append a dynamic ‘Log In’ link that changes to ‘Log Out’ (or ‘My Account’ for WooCommerce) based on whether the current user is authenticated. One function, no plugin.
Add an active class to parent menu items
Filter nav_menu_css_class to add ‘current-menu-ancestor’ or a custom active class to parent navigation items when a child page is active. Fixes common menu highlighting issues in themes that do not handle this natively.
Modifying WooCommerce without plugins
Change the Add to Cart button text
Filter woocommerce_product_single_add_to_cart_text (for single product pages) and woocommerce_product_add_to_cart_text (for archive pages) to change the default ‘Add to cart’ text. Return any string you prefer — ‘Buy Now’, ‘Add to Basket’, product-type-specific text.
Remove WooCommerce breadcrumbs
Remove WooCommerce breadcrumbs without a plugin: remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20);
Change the number of products per page
Filter loop_shop_per_page to return the integer number of products per page. Simple single-line change: add_filter('loop_shop_per_page', function(){ return 12; });
Custom login redirect
After login, redirect different user roles to different destinations. Filter login_redirect to check the user’s role and return the appropriate URL. Redirect admins to the dashboard, customers to their account page, subscribers to a specific content page. No plugin needed.
Need custom WordPress development or theme customisation?
Simple Automation Solutions builds and customises WordPress themes and plugins for businesses worldwide — writing clean, maintainable code tailored to your exact requirements.
Frequently asked questions
Is there a limit to how much code I should add to functions.php?+
There is no technical limit, but long functions.php files become hard to maintain. A practical threshold: when your functions.php reaches 200-300 lines covering multiple functional areas, consider splitting it into separate included files (require_once in functions.php for files like /inc/admin.php, /inc/woocommerce.php, /inc/customisations.php). This keeps the file organised by purpose without losing the simplicity of a single-entry-point file. Alternatively, create a simple custom plugin to hold the same code — it can be activated and deactivated independently of the theme.
What is the safest way to test functions.php code changes?+
Always test on a staging environment before applying to a live site. A PHP syntax error in functions.php causes a white screen of death that locks you out of the admin. If this happens: connect via FTP, navigate to your child theme directory, rename functions.php to functions.php.bak. This deactivates the file and restores admin access. Then identify and fix the syntax error before renaming back. Using a code editor with PHP syntax highlighting (VS Code, PHPStorm) catches most syntax errors before you upload the file.
What is the difference between a plugin and a must-use plugin?+
A regular plugin is installed in /wp-content/plugins/ and can be activated and deactivated from the admin. A must-use plugin (mu-plugin) is installed in /wp-content/mu-plugins/ and is always active — it cannot be deactivated from the admin and does not appear in the regular plugin list. Must-use plugins are ideal for critical site customisations (custom post type registrations, security hardening, performance configurations) that should always be active regardless of who has admin access. They are not updated via the WordPress admin and must be managed directly via FTP.
Simple Automation Solutions is a global digital product studio specialising in WordPress and Bubble.io. We serve founders, startups, and businesses worldwide — delivering production-ready websites built to rank, convert, and scale.
