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 created a custom field that allows me to set the cropping style of timthumb, but I am also using short code to populate a page with blog posts, but the shortcode isn't picking up the customfield, so all the images look different.

Here is the code from index.php

<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
  <img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $thumb; ?>&h=150&w=600&zc=1&q=100&a=<?php echo get_post_meta($post->ID, 'thumbcrop', true); ?>" 
       alt="<?php the_title(); ?>" />
</a>

Here is the code from blog.php (shortcode)

<a href="'.get_permalink().'" title="'.get_the_title().'">
  <img src="'. get_bloginfo('template_directory').'/timthumb.php?src='.$thumb.'&h=100&w=600&zc=1&q=100" 
       alt="'.get_the_title().'" />
</a>

The shortcode file hasn't been updated, as I'm not sure how to pass the customfield value.

Can anyone help out. Much appreciated.

share|improve this question
    
I don't understand your questions. In the first codesample, you add a GET parameter a with the shortcode's vaule to the image URL. You don't do so in the second. So why are you surprised you get a differeny effect? Note that you can use get_the_ID() instead of $post->ID. The former definitely works during shortcode evaluation. –  Raphael Jan 21 '12 at 11:46

1 Answer 1

could be a question of string concatenation - try (untested):

<a href="'.get_permalink().'" title="'.get_the_title().'"><img src="'. get_bloginfo('template_directory').'/timthumb.php?src='.$thumb.'&h=100&w=600&zc=1&q=100&a='.get_post_meta($post->ID, 'thumbcrop', true).'" alt="'.get_the_title().'" /></a>
share|improve this answer

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.