0

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);
1

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 ) );
  • tx, totally overlooked $content – alex Mar 7 '13 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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