Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.