I always break my functions.php up into more managable, specific functionality files, for instance, all footer related functions goes into a file called footer-functions.php
and pagination functions goes into a file called pagination-functions.php
. This way, my code stays organised, managable and I don’t kill my functions.php
. This however, is only related to theme specific functions, site specific functions goes into plugins in much more the same type of method
To come back to the point, at the end I include all my smaller specific function files into functions.php
with require_once()
as follow
require_once( 'footer-functions.php' );
require_once( 'pagination-functions.php' );
This is all you need. You should not hook this to any hook or add it in any function, it can have expected behavior which can lead to a broken site
Related Posts:
- Display random categories on the front page (Finding and Editing Theme Functions)
- Issue with get_theme_mod returning a blank value instead of the saved value
- Theme-Config tab in admin Pannel?
- Customizer field value into functions.php variable
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Add Custom Background Properties to Customizer
- unnecessary request call for js and css after calling wp_dequeue_script
- Where do I go to edit this area? [closed]
- Astra theme – cannot set short product description under the product title (product name)
- Header menu aligned right on all pages except for single-post page [closed]
- CSS style and app.js not loading
- Customizer cuistom CSS Priority ordre Issue
- Parse error after modifying the template menu [closed]
- Automatically include all php files in a child theme directory
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- WordPress PHP Conflicting User Sessions
- Move Custom Fields on General Settings Page to New Location
- Skeleton Child Theme Add Icon Bar to Header Flex Grid
- Impossible to call wordpress function inside an include?
- Customizer – loading settings/controls/sections/panels based on a id/page id
- Function that outputs second theme url
- different style sheet for just one page template
- Condition OR for current user ID
- How to retrieve the current post’s generated featured image size?
- Can I have an additional functions.php file in WordPress?
- Remove Custuomize Sections
- Not all CSS elements transferring via parent to child?
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Where do I store custom functions that call custom page template files?
- wp_star_rating() – Adding a 5 star rating system to theme
- Why There Is No “get content by ID” Function
- laoding bloginfo url in function array?
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Turn get_posts as string into an array for use in theme admin options
- Custom HTML markup
- Use a shortcode to display custom meta box contents
- Filter nav menu items HTML tags and wrap inner text with span
- Wp-query Order By problem
- Create custom function for hero image
- Randomizing wp_tag_cloud() in child theme
- Can’t switch to a child theme using filters template, option_template and option_stylesheet
- login_headertitle is deprecated since version 5.2.0
- How to append classname to body tag if guest user
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- Replace plugin function with a custom function?
- Add attribute only to first image of every post via functions.php
- How to edit alternate inactive themes in “Appearance -> Customise” screen?
- Different favicon on different pages
- The_content and Preg_replace in loaded Iframe [closed]
- Getting the teaser text without overriding global variables
- Default Nav Highlight
- Combine two active_callbacks into one on theme customizer
- Unable to point the child theme directory even using get_stylesheet_directory()
- Customizer: get_preview_url() inside customize_save_after hook
- WP Customizer API loaded into functions.php
- Can I include a custom PHP function in a WordPress function?
- How to pass variables from one function to another or combine functions
- get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
- Different methods of adding menu support to custom theme
- “options.php” not found
- Problem with images URL after filter applying
- two search forms on the same page
- How to override this theme function in child theme
- Function to replace comment’s accented characters before posting
- get_template_directory() – references parent theme directory
- Problem in using Customizer
- Insert a field with PREG_REPLACE – strange behaviour
- How to echo Widget Title in Custom Frontend-Template Box
- New checkbox in custom widget isn’t saving data
- Linking Javascript in functions.php file
- how to display a page before the home page
- loginout function customization
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- How do I preserve changes to a theme’s functions.php across updates?
- Can’t change theme name
- Theme Customizer – Custom Sections Display, but do Nothing
- file.php not loaded?
- Function to check if custom page is used by page?
- implementing a centralized content “show-do-not-show” toggle?
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- What function actually renders the wp_admin_bar ? How can I call it?
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- WordPress – using sessions?
- Why should I use get_template_directory() when include files?
- How to remove font awesome from loading in wp theme
- WordPress functions.php conditional include another functions file
- How to replace ACTION url from original wordpress login form?
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Save_post – Warning: Cannot modify header information
- How to use WP conditional tag in a functions.php with OCEANWP Theme?
- Class parameter in get_avatar args doesn’t get added to output
- Modifying a WordPress Plugin
- CF7 select value get to function and reciept value from function
- Hide author info in single posts by certain users
- How to add a custom class attribute into code wrapper? [duplicate]
- External api call and make global variable for any page visitor enters , page-home, page, single etc
- Parent category as WOOCommerce Categories widget title
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs