I am making a plugin, to register a shortcode, which when used like this: `[append_css mycss]` it will look for a custom field called `mycss` and add the contents to the `head` of the document. It all works great, except that the code is being added to the body, and I don't know how to get it to add to the head.

I have tried adding an action `wp_head` but I don't know how to pass variables whilst doing that, and it does not seem to fire from within the shortcode callback anyway.

```
function append_css_short($params){
  global $post;
  if(sizeof($params)){
    $key = $params[0];
  } else {
    $key = 'css';
  }
  return '<style type="text/css">'.
  get_post_meta($post->ID, $key, true)
  .'</style>';
}
add_shortcode('append_css','append_css_short');

```

How would I get this to write to the head instead of body?
Is there a better approach to the problem?