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
- what is correct way to hook when update post
- Custom plugin: Trying to show saved data on frontend
- Remove Woocommerce product link
- Check php version before theme activation
- What can I hook into after_setup_theme?
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- How can I hook into and edit the text of a wp_nav_menu tag?
- Check if page parent has certain template
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Prevent publish status/date saved on transition_post_status hook
- “wp_enqueue_style();” don’t load new edited style
- Woocommerce, recognize the loop of related products
- Is $hook a global variable in WordPress
- wp_enqueue_style with style.php and WordPress functions
- Executing `createimagefrompng()` from save_post hook (or equivalent hook)
- Getting my head round WordPress filter
- Delete option value from array using update_option()
- How to set a custom path, for ajax image upload folder in admin?
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- How to add a second ‘place order’ button in WooCommerce [closed]
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- Handling Body class based on Template
- How to load a template-part based on a url wildcard?
- ajax, right way to do it and make it works?
- Sending data from custom inputs in WordPress comment form in the admin notification email
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- How to only enqueue script if it’s a post
- Reload part of checkout on changed shipping method
- Trying to build simple deposit code that hooks into woocommerce
- Add a product to checkout via form
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- user_profile_update_errors hook not executing
- Set meta field to publish date + 2 weeks
- WordPress Gravatar filter is removing my custom attributes
- Return a numerical function value in Customizer controls
- 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
- Where is the right place to register/enqueue scripts & styles
- Need help enqueueing webfonts
- Font Awesome changing default WordPress Font
- How to change menu labels
- Should `wp_login` be used since it’s deprecated?
- Conditional Javascript based on WP Version
- 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 not calling Jquery properly
- WordPress redirect redirecting too many times or not at all
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- Enqueing External JS on the remote server JS
- Get user custom field value on function.php
- How to make a cookie be on the whole site instead of being on a specific page/
- Must filter functions receive all arguments passed to them?
- Dynamically Generate Functions and Hooks
- save_post trigerred twice
- Generate a QR code when creating a new WordPress user
- Filter wordpress posts without searching the keywords in the post content
- Variation prices breakdown only for single product page
- Display custom field value in woocommerce variable product via jQurey
- Add custom field on admin dashboard comments / reviews
- Dequeue styles with query doesn’t work
- Wp_Schedule_Event every few minutes doesn’t work
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Discount in the specific product title using keyword ( Woocoommerce )
- get Woocommerce product format json for WP_Query
- 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 remove an action hook inside a class that is called by another class?
- Hook into all password resets in WordPress and get password before hashing?
- Clone the “proceed to cart” button and place it above checkout on the cart page, but only appear display size is 320px
- Passing link parameter values to form
- wp add inline style in loop
- How to add custom checkout field in user details mail template
- Errors while Loading Most Recent Version of jQuery
- For each loop will not append to the_content hook
- 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
- How to enqueue structured data as file – jsonld file seems not to work
- transition_post_status hook, works – but not if the post is new
- php was updated – critical error [closed]
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- Woocommerce – add tracking code to another email template