WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering how i can handle a shortcode function directly? At the moment i have created a shortcode which works OK. The shortcode function outputs a image.

Now in functions.php i have another function which needs the output image. I am using the do_shortcode and it works.

$image = do_shortcode('[route_thumb id="'.$post_id.'"]') ;

but how can i call the function directly this one didn't work

 $image = route_thumb_function($atts['id']=$post_id);
share|improve this question
up vote 1 down vote accepted

Shortcode handler function receives two arguments array $attr and string $content. So to pass attributes to shortcode handler function, just pass it as array:

$image = route_thumb_function( array( 'id' => $post_id ) );
share|improve this answer
tx, totally overlooked $content – alex Mar 7 '13 at 8:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.