I’m not sure what you’re hoping for, but all you can really do is just move the code from one function into the other. global $post is also not doing anything, so removing that will save you a couple of lines:
/**
* Register template
*/
public static function register_styles_templates() {
add_filter('single_template', function($single_template) {
if ($post->post_type == 'profile') {
$single_template="/Users/smajlovs/Sites/newsacfoodies/htdocs/wp-content/mu-plugins/sacfoodies/profile-template.php";
}
return $single_template;
});
add_action('wp_enqueue_scripts', function() {
if (is_page('foodies')) {
wp_register_style('profile-style', content_url() . '/mu-plugins/sacfoodies/styles/profile-card.css');
wp_enqueue_style('profile-style');
}
return;
});
}
Related Posts:
- Enqueue assets from multiple directories using add_action/do_action
- Enqueue less file not working in child theme?
- enqueue hover function
- How to enqueue CSS and JS only on specific template?
- Deregistering a script in WordPress seems impossible
- Is the wp_enqueue method efficient?
- linking stylesheets and scripts with functions.php
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- Enqueueing a code block from an options framework
- Fatal error: Uncaught Error: Class ‘WP_Block_Styles_Registry’
- Load script and styles using an array of resources
- Chosen Select jquery Not Working in Plugin
- How can I print out a single stylesheet or javascript link?
- wp_enqueue_style conflict when using in different action hooks
- functions.php doesn’t load all custom theme assets
- Where is the right place to register/enqueue scripts & styles
- WordPress and event-driven programming – what is it about?
- Get only enqueued styles and scripts of the current theme
- Receiving Stripe Webhooks on a wordpress website
- Change the footer text on the login page
- How to remove a metabox from menu editor page?
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- How to execute a simple php script in WP (I don’t think wp_enque_script applies here)
- Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?
- Understanding child theme functions.php
- Is it possible to use the featured image of a page as a css background without inlining?
- if file_exists not working with wp_enqueue_style
- How To Change The Html of Products filtration sidebar in Woocommerce?
- Insert all post IDs in new database table
- Hook after wp_enqueue_scripts
- action hook wp_head higher priority as all other plugins/hooks
- WP CLI Get all Enqueued Scripts and Styles
- using add_action for a header hook that has an additional parameter
- How to remove scripts/style added to customize_controls_enqueue_scripts hook by current active theme
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- wp_loaded hook block script enquequing
- Remove an action hook within a Class
- Plugin CSS not enqueing
- How to pass arguments to add_action() or retrieve return value of called function?
- Parent theme CSS overriding child CSS rules
- hook that when page is starting to load
- How to change home or site url using action hooks or filter?
- Parse error syntax error unexpected t_string [closed]
- Edit incorrect password message WordPress
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Remove metabox from WordPress menu editor page?
- Why ajax doesn’t work on certain wordpress hooks?
- How to add an arrow to menu items has submenus
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Don’t insert if permalink is the same?
- how to make custom ajax handler?
- WordPress Scripts Being Loaded in Footer
- Whats the proper way to use a php stylesheet in a wordpress theme? [duplicate]
- Why does wp_head hook my functions to the beginning of my source code?
- Pass argument to event hook
- Correct way to enqueue page specific CSS file
- Double jQuery loaded
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- How to catch wordpress post ID when it’s published
- Why does the post_type_link hook everything twice?
- How to use wordpress function wp_enqueue_script() in php?
- How can I hook into the wp_mail function used by BackWPup?
- Trying to enqueue script – Nothing Happens
- Adding function to child theme’s function.php
- url_to_postid returns 0
- Add a custom class to the body tag using custom fields
- Why doesn’t global $wp_query not get hooked?
- How to pass hook variable to function?
- How do I add a function to parent theme
- Show full post instead of excerpt
- Use wp_head hook on template page
- Adding custom field to product category and show it to shop/category shop page
- How to edit post meta data before publishing the post it self wordpress?
- Custom meta box is not displaying value showing tag as empty
- using filter and hook inside class
- Get original value in save_post action hooka
- Enqueue sripts and styles only if function is called
- Register/enqueue scripts only on certain admin pages
- How do I get the value of a current user’s custom field?
- Help hooking into user_register
- add_filter() inside another add_filter()
- Getting page / post URL on publish and / or update
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- How to stop loading my custom scripts files for wordpress iframe?
- How can I move the posted-on date above the post and below the entry-header?
- Post formating on Home page
- Modify arguments for parent theme’s `wp_register_style` via child theme
- calling a function from a class in your template
- PHP Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered
- Cannot modify header information – headers already sent
- Change Checkout “Place Order” text if cart has a specific product
- Send a custom notification to customer on WooCommerce cancelled order status
- Warning: filemtime(): stat failed for wp_
- How to enqueue structured data as file – jsonld file seems not to work
- php was updated – critical error [closed]
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- in_footer: gives syntax error
- Add Imports to Existing WordPress Import Map