I'm trying to create a wrapper shortcut function to register and load stylesheets in the header. currently, the function loads this css file src:
http://my.test/wp-content/theme/css/.css
I, obviously want it to pass the parameter given. The problem is, the new function definition within the new function definition doesn't seem to be taking the parameter even though my #4th argument for add_action was 1 (parameter passable to function).
What am I doing wrong?? Please help :)
<?php //Registering stylesheets
load_stylesheet_like_a_boss('my-style.css');
function load_stylesheet_like_a_boss($filename){
echo 'parent:'.$filename; //should return 'parent: my-style.css'
add_action('wp_head', 'stylesheet_registration', 5, 1);
function stylesheet_registration($filename){
echo ' / child:'.$filename.'<br>'; //should return ' / child: my-style.css'
$name = str_replace('.css','', $filename);
wp_register_style($name, get_bloginfo('template_directory').'/css/'.$name.'.css');
wp_enqueue_style($name, 10);
}
} ?>
load_stylesheet_like_a_boss(), and why do you need to use the wrapper, instead of simply creating a hook callback to enqueue your stylesheet? – Chip Bennett Feb 14 '12 at 14:00