Justin Tadlock recently wrote a great post about making a better functions.php file
where (if I remember correctly) he deals with this exact issue.
Unfortunately his site is down at the moment so I have to rely on my memory for now.
You are on the right track with the after_setup_theme
hook.
- As far as I remember the trick is to wrap your filters and actions into it’s function.
See example below. - You do that in both parent and child
functions.php
files. - Then you can play with the priority of these two hooks.
Little bit of code worth thousand words – your parent theme’s function.php
should look like this:
add_action( 'after_setup_theme', 'your_parent_theme_setup', 9 );
function your_parent_theme_setup() {
add_action(admin_init, your_admin_init);
add_filter(the_content, your_content_filter);
}
function your_admin_init () {
...
}
function your_content_filter() {
...
}
Related Posts:
- Missing feature image link function
- How to customize the_archive_title()?
- When should you, and when should you not, use wp_list_pluck()?
- Difference between the_permalink() and get_permalink() function
- WordPress Enqueue for homepage only, functions.php, wp-framework
- How to show product SKU on product page
- Gettext details
- Is it possible to remove the main rich Text box editor?
- Calling a function from functions.php in header [closed]
- Dynamically add sub-categories to any category in the menu
- Is there a way to push javascript or css ‘on-page’ in a template via functions.php
- Adding Google Analytics to footer selectively
- How to change a certain text or term of WordPress into a custom into the whole site?
- Different functions file for each site in multisite installation?
- jQuery plugin function is not a function
- I changed “Howdy” in the admin bar in the dashboard, but when I’m viewing the site it still says Howdy!
- Template tags vs get_template_part() vs functions.php
- Custom logo sizes for multiple logos
- How to Add a Random Custom Gravatar in the WordPress Comments?
- how to change link of some wordpress pages
- Loop (iterate) through Multi-Site sub-sites (blogs)?
- Proper way of using functions in action hook?
- Custom function for specific user role
- Add custom image size not working
- When to use an if statement after get_posts?
- Programmatically Create Category and sub Category
- How to mass-delete inline styles in WordPress custom post type automatically?
- wp_get_attachment_image function size argument not working if I also add a custom class
- functions.php mistakenly deleted
- Not sure if enqueuing js scripts properly
- Shortcode inserts paragraphs before and after executing shortcode
- Get_template_part inside a folder
- Passing values from a widget to a function within a plugin
- Contact Form 7 – Delay auto responds
- add code in functions.php will slow down the Execution speed?
- Replace a menu with widget or a custom template file programmatically
- Which functions/classes are available during SHORTINIT?
- Function added using `add_action()` not being called
- How to stop wordpress from injecting hard-coded style into image attachments with captions
- How to pass variables from a function in functions.php to an other one
- Two functions with different arguments and add_actions, but identical code
- How to fix get_the_category function returning incorrect slug?
- How to edit the Tags within the image file URLs?
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- Add code to Functions.php
- Disabling visual editor on a specific post
- Disable wp_is_mobile()
- How can we know we are not in edit page
- Adding jQuery datepicker to Custom Post Type Metabox [closed]
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in …\wp-includes\functions.php
- What happens to the text in functions.php file outside of the php enclosure?
- wordpress acts like functions.php doesn’t exist [closed]
- How to get post revisions in my custom rest API? [closed]
- retrieves menu and converts it to a readable array
- Strip div From Excerpt
- How to properly set custom logo size?
- Image Crop Not Working
- WordPress can’t get jquery/unslider to work
- how get number of twitter followers in wordpress
- Function to check if custom page is used by page?
- template_redirect action only firing if logged in
- Unable to use get_page_by_title() more than once per page?
- How to Display WooCommerce Product Price in WooCommerce Archive
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Featured Image and Tags problem
- Advanced method to control cache of enqueued style/script
- Bizarre Child Menu Issue on WP Site
- get variables data from functions.php to template wordpress (without global variables)
- large image size of 1440×1440 not pulling 2x of 2880×2880 image
- Shortcode to insert default text and change one word throughout it?
- Its my first time trying to create a website , I got an error Please help
- Drop down list code for sidebar
- Shortcode Initialization in a Custom Theme
- Hide disclaimer from summary excerpts
- Load scripts into an AJAX div
- restrict uploaded image size and fixed image display size
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Function not receiving string from shortcode
- I’m getting invalid taxonomy in init action
- Restricted images only for logged user. (hidden url)
- Only seems to be displaying one child when there are supposed to be multiple
- Rest API User Levels
- adding google analytics via echo or between tags
- Slider Thumbnail Size Issue [closed]
- WordPress permanently logging users out
- Meta Box value not been pulled in
- Override parent theme function that is not hooked or in the functions.php file
- Syling Custom Fields echo’s from from functions.php
- How to Update User Meta Field other than from profile?
- Retrieve array of attachment IDs attached to a given Post ID
- More link – not text
- WP Custom Comment Callback Not Responding
- Shortcodes not outputting in correct divs
- Help finishing script to export WP user data when form submitted
- How I can show short content with short tag
- PHP Notice: Function is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false
- Different ads on every website on multisite environment
- WordPress Custom wp mail template return full template
- How to get variable from other function inside class function using add_action for Ajax call