Custom background for the index page only?

You can check in your callback function if you are an the front page. Sample code for the theme’s functions.php: add_action( ‘after_setup_theme’, ‘wpse_67480_theme_setup’ ); function wpse_67480_theme_setup() { $bg_options = array ( ‘wp-head-callback’ => ‘wpse_67480_background_frontend’, ‘default-color’ => ‘f0f0f0’, ‘default-image’ => ”, ); add_theme_support( ‘custom-background’, $bg_options ); add_theme_support( ‘custom-header’, array ( ‘width’ => 960, ‘height’ => 200, … Read more

Display custom_background outside wp_head()

custom_background() places the CSS to wp_head() as you mentioned so to get those CSS as if you don’t have wp_head() in your header, these tweaks from the core files would help: function wpse_228588_background_image_css() { $background_styles=””; if ( $bgcolor = get_background_color() ) $background_styles .= ‘background-color: #’ . $bgcolor . ‘;’; $background_image_thumb = get_background_image(); if ( $background_image_thumb … Read more

Add custom background to div in home page

Use the wp-head-callback argument to specify your own handler: add_theme_support( ‘custom-background’, array( ‘wp-head-callback’ => ‘wpse_189361_custom_background_cb’, ‘default-color’ => ‘000000’, ‘default-image’ => ‘%1$s/images/background.jpg’, )); function wpse_189361_custom_background_cb() { ob_start(); _custom_background_cb(); // Default handler $style = ob_get_clean(); $style = str_replace( ‘body.custom-background’, ‘#featured-home-image’, $style ); echo $style; }

How to get attachment id of background image?

Query for post meta keys _wp_attachment_is_custom_background or _wp_attachment_is_custom_background: function t5_bg_img_id() { if ( ! $bg_img = get_background_image() ) return FALSE; $query = array( ‘post_type’ => ‘attachment’, ‘fields’ => ‘ids’, ‘meta_query’ => array ( array ( ‘key’ => ‘_wp_attachment_is_custom_background’, ‘value’ => get_option( ‘stylesheet’ ), ‘compare’ => ‘==’, ), array ( ‘key’ => ‘_wp_attachment_metadata’, ‘value’ => basename( … Read more

How do I add settings to the Background Options Page?

The page content for custom backgrounds is created in wp-admin/custom-background.php. There is no action available where the fields are printed. To add new fields we have to print JavaScript into the page footer. The action is ‘admin_footer-appearance_page_custom-background’. To save those field values we have to hook into ‘load-appearance_page_custom-background’. The following example adds a new option … Read more

featured image as background image on pages

You need to echo the return value from wp_get_attachment_image_src(). It also returns an Array(), so you need to grab the needed part from that array. In this case it’s the first/0 value. Example: <?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘full’ );?> <div id=”post” class=”your-class” style=”background-image: url(‘<?php echo $thumb[‘0′];?>’)”> <p>your text demo</p> </div>

techhipbettruvabetnorabahisbahis forumueduedusedueduseduedusedusedueduedu