I am trying to create a post where i am uploading some media while creating a new post (i have created a custom post type for this purpose). Now this media doesnt need to be inserted in the post, but to be used in my category template file, wherein i have to set it as a background. Now what i am doing currently is –
yeah, thats what I am doing currently, defining classes manually, uploading the images before and setting the custom field in the post for classname ( above the custom fields name is “bgImageClass” ) so I wanted some alternative to this where I can upload and use on post by post basis
You can upload the file to your media library, copy the url, and use that as the value for a custom field instead of assigning the background by selecting a class.
However, you’d need to a) set the background image value as inline css (or in your header) in your template, or b) you’d have to rewrite your template so that the image is behind your content as an image, not a div with a background.
By the way, if you’re using custom images like this regularly, you can make the upload + assign value process even easier by using the Advanced Custom Fields plugin as well, which allows users browse-and-upload functionality right from the edit page.
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘inserting media into post and then making it a background of some div?’ is closed to new replies.