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
- Adding widgets to my plugin page instead of WordPress dashboard
- edit_comment_link is not showing for comment author
- Adding function to Genesis genesis_header [closed]
- Modify custom field input data before creating a new post
- how to make custom ajax handler?
- Are all hooks/functions tied to Kses meant for sanitization?
- WordPress Scripts Being Loaded in Footer
- Where is the right place to register/enqueue scripts & styles
- Need help enqueueing webfonts
- Whats the proper way to use a php stylesheet in a wordpress theme? [duplicate]
- Font Awesome changing default WordPress Font
- Jquery function working in Dev Console but not otherwise [duplicate]
- responsive.css in the WordPress should be prioritized
- How to change menu labels
- Which is the correct way to conditionally enqueue a CSS file?
- jQuery code not working when included in functions.php
- Why does wp_head hook my functions to the beginning of my source code?
- Pass argument to event hook
- How to remove woocommerce_breadcrumb() from do_action( ‘woocommerce_before_main_content’ ); [closed]
- Should `wp_login` be used since it’s deprecated?
- Conditional Javascript based on WP Version
- Correct way to enqueue page specific CSS file
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Password minimum length in personal subscription [closed]
- How to use a custom hook
- Run a code only on theme activation only during first activation
- Theme activation hook in php class
- Double jQuery loaded
- Register/enqueue scripts only on certain admin pages
- How do I ensure I can loop through every enqueued script and CSS?
- Importing the style and scripts in the plugin doesn’t work as well as in the theme
- How do I get the value of a current user’s custom field?
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Help hooking into user_register
- add_filter() inside another add_filter()
- When to use wp_register_script() function?
- Hook into all password resets in WordPress and get password before hashing?
- Getting page / post URL on publish and / or update
- Add class to all meta boxes for a custom post type
- 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?
- Why transition_post_type hook is called twice for the same post?
- Clone the “proceed to cart” button and place it above checkout on the cart page, but only appear display size is 320px
- How can I enqueue comment-reply script only on certain page?
- How can I move the posted-on date above the post and below the entry-header?
- Passing link parameter values to form
- Post formating on Home page
- Modify arguments for parent theme’s `wp_register_style` via child theme
- WordPress HTML Helper
- calling a function from a class in your template
- wp add inline style in loop
- Adding javascript files to WordPress and jQuery version
- PHP Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered
- How to add custom checkout field in user details mail template
- How to NOT override inline css rules
- Adding Gravity Form With if(is_page) Is Not Working
- Cannot modify header information – headers already sent
- Errors while Loading Most Recent Version of jQuery
- For each loop will not append to the_content hook
- Change Checkout “Place Order” text if cart has a specific product
- Send a custom notification to customer on WooCommerce cancelled order status
- Assign new post author IF another user in custom field on post transition
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- Warning: filemtime(): stat failed for wp_
- How to enqueue structured data as file – jsonld file seems not to work
- understanding wp_next_scheduled
- Add/alter image attribute before render
- Make a variable global and use it for inline script
- transition_post_status hook, works – but not if the post is new
- php was updated – critical error [closed]
- Guests comment form – prevent duplicate email addresses
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- Styling best practices for single pages/templates
- Woocommerce – add tracking code to another email template
- Is there a hook that I can use when a fatal error occurs?
- Is there a way to pull remotely generated XML, process it, and display it on a Managed WordPress page?
- how to append ACF field data using one of the following filter/ hooks
- in_footer: gives syntax error
- Custom gutenberg block refuses to load viewScript and I don’t know why
- Custom filter not affecting gtag script position in WordPress footer
- Responsive images, per image type?
- Add Imports to Existing WordPress Import Map
- WordPress generating Undefined Variable warning