You’re much better off with using a (mu-)plugin. Just add a folder named mu-plugins
in your wp-content
directory and place your files there. Then add a plugin header comment to it:
<?php
/**
* Plugin Name: Some Name
* Plugin URI: http://example.com
* Description: Loads something
* Version: 0.1
* Author: Akamaozu
* Author URI: http://example.com
* License: GNU GPL 2 <https://gist.github.com/1365159>
*/
// deny direct file access if WP not loaded
! defined( 'ABSPATH' ) AND exit;
// define your functions here
function foo()
{
print '<h1>'.__FILE__.' loaded successfully!</h1>';
}
add_action( 'shutdown', 'foo' );
Related Posts:
- get_template_directory_uri pointing to parent theme not child theme
- Include PHP file in Content using [shortcode]
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- What is the most efficient method for loading widgets in functions.php
- PHP files included in functions.php don’t seem to work
- Include files in child themes, declare in functions.php
- using `require` in my functions.php breaks the site
- Automatically include all php files in a child theme directory
- Impossible to call wordpress function inside an include?
- Can I have an additional functions.php file in WordPress?
- wp_star_rating() – Adding a 5 star rating system to theme
- Unable to point the child theme directory even using get_stylesheet_directory()
- Can I include a custom PHP function in a WordPress function?
- file.php not loaded?
- Why should I use get_template_directory() when include files?
- WordPress functions.php conditional include another functions file
- Including admin-options.php file in Child Themes
- Undo a function that is not (seemingly) hooked to an action?
- How to check if a user exists by a given id
- Get list of years when posts have been published
- Redeclare a function in a child theme
- Do WordPress’ cron’s clean up expired transients?
- How to add first name & last name to default registration form?
- Masking logout URL
- How can I programmatically create “child” pages on theme activation?
- Add admin bar link to edit author
- How to include one class/instance without using global variables
- Modify search function in WordPress (TwentyTwelve)
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- How to Acheive the custom woocommerce category template
- How to add CSS style sheet dynamically in wordpress
- How to update BuddyPress xprofile fields programmatically? [closed]
- Replace Archive Widget Link Text
- A snippet after every image
- Programmatically set page template based on page ID
- How can I add an image field to BuddyPress Extended Profile Fields? [closed]
- wp_remote_post with ssl:// protocol
- Best way to programatically add “rel” attributes to page and post images
- Searching for content post
- How to include local menu based on page id?
- How to add custom fields to my custom registration form
- Add Featured image column into wordpress admin on pages AND posts
- How can I change the do_action function in footer (copyright area)
- How to display post content instead of excerpt
- Override a theme function in a child theme?
- changing behaviour of get_search_form
- Which action does wp_update_user triggers?
- How can I get my Script to work on the Login page?
- WordPress menu link doesn’t work properly
- Custom shortcodes not inserting into visual composer columns
- Add custom function to a theme with child theme’s functions.php
- Post meta not updating
- Why doesn’t is_page(id) work in functions.php?
- Does code run faster in functions.php than in different theme templates?
- Function to alphabetically sort custom post types creating duplicates
- How do I call a function to use on a page?
- get_post_meta() problem again
- Update users custom profile fields
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Add back in child theme what the parent theme removed with remove_action
- replace text in Sort Box
- login_headertitle is deprecated since version 5.2.0
- Prevent loading of functions
- Where is this JQuery coming from?
- Different favicon on different pages
- What is the better for call files: bloginfo() or echo esc_url()?
- WordPress website keeps loading the maintenance page
- Setting Permalinks in wp_config or functions file?
- loginout function customization
- Dashboard blocker on network multisite for specific user roles
- How to place a div inside a function that creates a div
- Echo post title in post
- dynamic enquiry form [closed]
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- How to redirect Subscribers on login to specific page, when logging in from a Page
- How to load a css file depending on the current role
- How to change images url in function.php?
- Which filter fires upon setting a featured image
- Add a word after the post url if it is within a specific category
- Probleme shortcode with list author
- Stylesheet does not load despite functions.php
- How to show only specific category post by user role without plugin and restrict all other cats
- Shortcode to output category description by passing ID
- Unable to declare AOS library in functions
- Removing sanitize_title_with_dashes Function with The Real Title
- Graphic before title – Specific Category
- Printing medium sized image
- Filter posts on new page
- Sticky – Featured Image
- Edit meta fields from within template
- WordPress Jquery+scripts enqueue issue
- Adding a meta box fields to child theme options page
- Adding a jQuery rotator function
- How to pass a variable from a template page to the child theme functions.php
- How to programmatically GET (to know) which Sidebar (or) which Menu is being used on Different Pages?
- Can’t change excerpt length and more tag
- Making an under maintenance page (without using plugins)
- Image width issue in IE [closed]
- Changed functions.php file and now site is blank [closed]