How to set featured image using shortcode



Shortcodes are for content areas that the post author can type into.
Featured image is an entry in the post meta table containing image information to associate with a post.

What exactly are you trying to accomplish? These two things can’t just be merged, but you can write a shortcode to show an image in the content, and you can assign featured images programmatically.
(and neither have anything to do with CSS)

The shortcodes I am talking about are like the Getty images Embed codes.

At present, to set the feature image I would have to upload the image from my media library. There is no option to set the featured image using a shortcode.

Is there a plugin or css code that will allow me to set the featured image by using these types of shortcodes (e.g, if I wanted to set the featured image by using a Getty images Embed code)



Those two things are very different.
There are plugins that allows you to set the featured image using a URL.

or generate the featured image from the first image in the post

I tried the 3rd option. The auto post thumbnail plugin. It only works if the image itself has been uploaded onto the post as a jpg or png file. It doesn’t work if you put the image on the post as an embedded code.

Is there anyway to use the auto post thumbnail plugin, so that even if the first image in the post is embedded code, it will still generate the featured image.

Or surely there is some CSS code that can be inputted, so that the featured image is generated even if the first image on the post is embedded code.



You could search for other similar plugins, or ask at that plugin’s forum.

Get it out of your head that you can do anything like this with CSS. CSS is styling what is in the page and that’s it. It is declarative, not functional. It doesn’t add content to the page.

Thanks for your help. I will ask on the plugins forum.

Source link