1

I currently have a site that uses the "custom fields" feature to set the value of the meta property="og:image" for each post. All of my og:images are stored on an external server.

I'm looking for a way to automatically set the "featured image" value with the value of the custom field for og:image.

My template does not display the "featured" image on each post, but it does display the featured image on the home page and on the category pages.

enter image description here

Code used to set og:image value

<meta property="og:image" content="<?php $post_id = get_the_ID(); echo get_post_meta($post_id, 'og_image', 'true'); ?>" />

Any ideas or suggestions?

I'm not a coding expert. I know enough to 'tweak' things and not break thing, but I'm no developer.

  • I think the question about having external image as a featured image was asked several times (I assume that almost always there are comments about possible copyright violations by using such feature), you should try the site search. As for not being a developer, I sympathize but , this is not going to be an easy one liner. If the amount of pictures is not big, you might do better by manually uploading them. – Mark Kaplun Jan 31 '16 at 19:43
  • @MarkKaplun Thanks for your response. I've seen them, but I haven't seen one that targets the value stored in a 'custom field'. The copyright issue is not a concern of mine. All the images are mine and on a server I control. If it is a complicated solution, I'm willing to work on it. If the code isn't easily written, I'm looking for a starting point and some logic so I can begin the process. Any help is greatly appreciated. Thanks! – Mr. B Jan 31 '16 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.