Including PHP files inside actions isn’t recommended, and is considered highly unusual. If what you were trying to do worked, it would be fragile, and heavily dependent on ordering.
The reason your code didn’t work:
add_action('wp_head', 'fst_include',20);
Is because actions are added with a priority of 10
by default, yet your include is on priority 20, so it happens after the other hooks, not before. As a result, when more_css
is executed, it has yet to be defined.
Instead, don’t load the file on a hook, just load it immediatley so that the functions are defined, but not executed, then add the functions as actions.
In general, it is a bad idea to mix loading code, and running code. Try to:
- Load the code or autoloader
- Create all the objects but don’t run them
- Then run it once everything is assembled
Related Posts:
- Is there any way to use get_template_part() with folders?
- How to include template according to meta post value
- Passing variables to template parts
- get_template_part for template in subdirectory not working
- How to add variables to a template
- Get name of the current template file
- How do you find out which template page is serving the current page?
- How can i change email template for new user
- Enable page templates. How?
- Is it possible to override the result of get_template_part()?
- How do you access the Product Short Description in a WooCommerce email template? [closed]
- View WordPress page template usage (or unused)
- Custom templates folder
- How do I get the URL of a specific size featured image?
- Create Page that uses specific template
- Sharing templates with the JSON API?
- index.php template is used instead of blog page
- Proper Javascript Implementation
- Guest author’s post not display in author template
- How to apply a custom template for posts by default?
- Force all images to full size in page template
- Login WordPress website using wp-rest api
- Global variable set in the template’s header.php is unable to echo in footer.php
- Is there a way to check which template file is being loaded, if it is not a page template file?
- How to remove wp_link_pages() from template
- How can I get WP to use templates in lower-level subfolder?
- WordPress Schema.org Markup. What value does it add?
- how to make a home page for wordpress custom theme
- Generate Catalog Of Posts Based On Template
- Extending body classes in front- and backend
- How do I find the directory of a page template?
- Is there a way to set different post templates for parent posts and child posts in the same post type?
- How do I insert JS tracking code to a page with the WP editor?
- Why write markup for index.php?
- LaTeX for WordPress strips codes in loop
- Rewrite Rules to custom template
- Having trouble with Template hierarchy. I Need to create a set of pages that drill down from states to specific locations
- How can I hardcode template selection?
- Use of Templates in a Plugin
- Changing layout programmatically
- How to identify which template WordPress’s default search-form retrieves in my theme
- How to use same page template if post status other than ‘publish’?
- Different Template based on HTTP Referer
- Where is Number of Posts Set?
- How do I override the search template in a plugin?
- Is there any way to write custom HTML is some .php file and then call it wherever necessary?
- How to redirect my custom template page to content-none.php if no posts found?
- Get URL of current post but not the page number
- Is template name always same as directory name?
- Single Post Breadcrumb not linking back to Custom Post Type Index?
- Form post to WordPress page = wrong template
- Automatically use specific template to load subpages
- get_month_link uses what wordpress template?
- Load custom script on a single template
- Archive template limiting to 4 entries?
- Author template help. How to check if field exists in the profile?
- Can you use block patterns in block templates or insert them programmatically?
- Not so common HTML transition to wordpress issue
- WP redirect to custom login page if a user is not logged in
- Change default template in the block editor (Gutenberg)
- Single-page.php template file name not shown
- How do I create post template for different taxonomy
- Ip2location plugin in my template header?
- Import a header template from another theme
- Will placing custom templates in sub directory break any native WordPress functionality
- How are the HTML classes generated?
- Page Template with Sidebar Naming Convention?
- Adding text to the footer of each post based on tags or categories
- Archive-custome_post.php template not working
- Change “posts per page” depending on width
- How to slice down index.php from a template and import from another file?
- Blog page won’t show Blog template
- Can index.php take over for front-page.php in template hierarchy on second page?
- What filter or action hook to use in order to load some code before the template begins printing in BuddyPress? [closed]
- How can I abstract code out of a template by using functions.php
- Make Permalink go to specific template
- Do not trigger page 404 on custom template
- How do I get tags linking to proper pages (/tag/sample-tag -> pages with that tag)
- How to name custom search page PHP file?
- Page Template Selector Error
- Assign template to custom page type?
- Accidentally deleted code in header.php
- Custom post template
- Change Page Template Based on URL Rewrite in WordPress
- Main content not displaying using custom page template
- plugin overwrites other plugin’s archive-.php file
- Creating custom URLs with template to fetch external JSON
- How can I display a list of pages and the template used by each?
- WordPress Child Theme Template auth_redirect wrapper
- Templates for Mobile Site
- Where is search.php?
- Including Custom Template on template_include Filter not working
- Is it possible to return a specific tag archive/template as one of the search results?
- A page created with url of blog redirects to the posts page, how do I stop this?
- WordPress templates bug
- Taxonomy Parent not showing up in address bar
- wp e-commerce single-product template giving 404
- Strange Behavior of Page Template Dropdown
- WordPress Template works until page becomes a child
- WordPress -> PHPBB look a like