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

  • 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() – Adam 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=""  />
| improve this answer | |

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.