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

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

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.