add class to background image

I have added the style “background-position: center center;” and it work perfectly! So the new code will look like this: <?php global $post; $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, ” ); ?> <div class=”mainblogwrapper” style=”background-image: url(<?php echo $src[0]; ?> ) !important; background-attachment : fixed;background-position: center center;”>

Different body image backgrounds on different pages, posts and categories

You need to add the classes for the corresponding cases. For pages/posts: $css = “body.page-id-**post_id** { background-image: url(‘$bg_image’); }”; For categories: $css = “body.category-**category_id** { background-image: url(‘$bg_image’); }”; You can retrieve post_id with $post->ID. For the category you need to check whether the page is_archive() and to append the corresponding ID or category name.

custom-background callback breaks media uploader

Long shot, but if you happen to not follow the recommended format and include the number sign with the HEX code when you define the default colour in your theme support, like this: if (function_exists(‘add_theme_support’)) { $defaults = array(‘default-color’ => ‘#666’); add_theme_support( ‘custom-background’, $defaults ); } Then, with your code above, you will end up … Read more

Return value of get_background_color

To add custom background support in your theme you need to register the default custom background support. Example:- add_action(‘after_setup_theme’, function(){ add_theme_support( ‘custom-background’, array( ‘default-color’ => ‘black’ //Default color )); }); Now you will see a new section Background Image in customizer and in Color you will see a new option Background color Once you will … Read more

Jumbotron not showing up on Firefox or Safari

Maybe you CSS code is confusing the other browsers. First you are using the prefixed properties after the unprefixed ones, I would inverse that. Secondly you are using the background shorthand property with the values in uncommon order. I think there are browsers out there, which expect them in specific order. .jumbotron { background: url(‘<?php … Read more

Setting up Custom Background [closed]

Use this css style to make your background cover the entire page: body { background-image: url(‘IMAGE URL’); background-repeat: repeat; width:100% overflow:hidden; float:left } Now, style your content’s background: .grey { background-color: #e6e6e6; display: block; float:left; overflow:hidden; width:500px // You can also set as 100% } Not that you should either set a width for your … Read more