- This topic has 10 replies, 2 voices, and was last updated 7 years, 11 months ago by
Tom.
-
AuthorPosts
-
April 9, 2018 at 1:46 pm #545696
infocus
Hello Tom! I have a question, with your extense knowledge maybe you have a solution.
I am create a site in Generatepress with the posibilty of agregate SVG image for the feature image (i think that is more fast and easy instead create image for each post) and i whant to select a background color for each post created for the feature image svg (post 1 – feature image with backgrond blue, post 2 – with feature image background red, etc).Do you know how can y do it or what is the function for it?
Thank you!April 9, 2018 at 9:05 pm #545940Tom
Lead DeveloperLead DeveloperHi there,
Not too sure what you mean. Are you wanting to give all of your SVG images a default background color?
I think you can use
fill, but I don’t know a lot about SVGs: https://stackoverflow.com/questions/44198625/how-to-change-background-colour-in-an-svg-imageApril 10, 2018 at 7:53 am #546392infocus
Hello, i am not refer to the svg (that is only a mension), i am refering to Pick a Background Color for each feature image background post (the image selected to the post). For example, in your theme i can select a color for the header, the footer, etc. I want to do the same por each background of the feature image (in my case an svg or transparent image).
April 10, 2018 at 8:58 pm #546914Tom
Lead DeveloperLead DeveloperYou could use CSS to set the backgrounds. If you use Simple CSS (https://en-ca.wordpress.org/plugins/simple-css/), it adds a metabox to each page which you can add CSS to.
Something like:
.featured-image { background-color: red; }April 10, 2018 at 9:17 pm #546937infocus
Thanks you Tom, but i am searching more for somethink like Color Pick Función of WordPress or somethink like that. You use this función for the selection of the colors,i want to use that función but Will be apply for each post. I have the perfect design for this website in my mind (and i will to Share it in your foro soon)
😉April 10, 2018 at 9:20 pm #546942infocus
PS. CSS on each post is like:
2000 posts > 2000 CSS sheets
April 11, 2018 at 9:24 am #547518Tom
Lead DeveloperLead DeveloperUnfortunately there isn’t a built in color picker that can achieve that.
Wouldn’t you need to use the color picker on each post anyways, if each post needs a different color?
April 11, 2018 at 10:42 am #547619infocus
Yes that is the idea, use in each post the color picker, this can be asociate to a list of CSS colors prdefined, for example, red:#ff000; blue:#0000ff; like a class. Or, you know some way to put a class in a post? Then i can put this class “red” and include the class in my css style.
April 11, 2018 at 8:56 pm #547952Tom
Lead DeveloperLead DeveloperYou could use the custom fields metabox (core WP). If you don’t see it, click “Screen Options” at the top right of the screen, and check the Custom Fields option.
Then add a new field, and give it a name:
featured_image_backgroundThen give it a class value:
redThen add this function:
add_filter( 'post_class', 'tu_add_post_class' ); function tu_add_post_class( $classes ) { if ( is_single() && get_post_meta( get_the_ID(), 'featured_image_background', true ) ) { $classes[] = get_post_meta( get_the_ID(), 'featured_image_background', true ); } return $classes; }April 15, 2018 at 2:04 pm #551124infocus
Muchas gracias Tom, funciona muy bien!
April 15, 2018 at 9:06 pm #551279Tom
Lead DeveloperLead DeveloperAwesome 🙂 Glad I could help!
-
AuthorPosts
- You must be logged in to reply to this topic.