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 am trying to return a screenshot from websites using this

<img src="<?php echo 'http://s.wordpress.com/mshots/v1/'.urlencode('http://domain.com/').'?w=200' ?>" />

This works fine for the current domain.com, I am trying to combine this with a custom field where I normally enter

<?php the_field('website'); ?>

I have tried the following

<img src="<?php echo 'http://s.wordpress.com/mshots/v1/'.urlencode(the_field('website'); ').'?w=200' ?>" />

But it doesn't seem to work. Any ideas?

Thanks Richard

share|improve this question
    
As shown below, you need to remove the semi colon and use get_the_field() so the custom field result is returned and not immediately echoed as when using the_field() –  userabuser Jul 6 '13 at 13:09
add comment

1 Answer

i think there is an error -

<img src="<?php echo 'http://s.wordpress.com/mshots/v1/'.urlencode(the_field('website'); ').'?w=200' ?>"  />

it should be

<img src="<?php echo 'http://s.wordpress.com/mshots/v1/'.urlencode(the_field('website').'?w=200' ?>" alt="" />

And if this not work.

I think you use the_field('website') function which actually not return result you can try

this code.

<img src="<?php echo 'http://s.wordpress.com/mshots/v1/'.urlencode(get_the_field('website').'?w=200' ?>" alt=""  />
share|improve this answer
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.