12

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: ...


7

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-...


4

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', '...


4

You can use a jQuery plugin called Color Thief. Files needed: jquery.js (is included in WordPress) quantize.js (download from color-thief github page) color-thief.js (download from color-thief github page) Wordpress setup: Open functions.php (located in your theme's folder) and add the code below to load the files in WordPress. In this case I placed all ...


4

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(); ...


4

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 ...


4

Try something like this: <?php global $post; $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' ); $default = get_template_directory_uri()."/assets/images/backgrounds/highway.jpg"; $bgimg = (isset($src[1])) ? $src[0] : $default; ?> <style type="text/css"> .parallax { background-image: url(<...


3

Take a look in the source code, and you'll see the body tag on every page and/or post has a unique class associated with it (postid-1241 for example). Select that class and change the background image there. Example: body.postid-1241 { background: url(http://example.com/bg.png) fixed; }


3

It sounds like you just need to remove support for the custom background color. remove_theme_support( 'custom-background' ); You will probably need to hook it to get it to run after the parent functions.php function disable_bg_wpse_97248() { remove_theme_support( 'custom-background' ); } add_action('after_setup_theme','disable_bg_wpse_97248',100)


3

You are putting an image into the style attribute - this is wrong. You only need the path, not a tag: <div class="art-header" style="background-image:url('<?php header_image(); ?>'); background-repeat:repeat; height:<?php echo get_custom_header()->height; ?>px; width:<?php echo get_custom_header()->width;?>px;"> </div> ...


3

Yes, this is possible. You can access the custom background image directly with get_background_image(), like this: echo '<style>body.custom-background {background-image: url(' . get_background_image() . ');} </style>';


2

I'm using child theme with twentythirteen parent. Made a directory with images in my child theme. But first removing default 2013 theme headers. /* Add custom headers from my child theme */ add_action( 'after_setup_theme', 'childtheme_setup' ); if ( ! function_exists( 'childtheme_setup' ) ): function childtheme_setup() { /* Remove Default Headers *...


2

Inside the theme folder there should be a file called functions.php. Search for the line add_theme_support( 'custom-background' ); and replace it with #add_theme_support( 'custom-background' ); which is simply 'deleting' calling the function and thus the possibility to specify a custom background in the admin side.


2

By default, WordPress uses the _custom_background_cb() function to create the style you show in your question. You can use a function of your own by adding it to the add_theme_support() in your theme. add_theme_support( 'custom-background', array( 'wp-head-callback' => 'wpse_113346_custom_background_cb' ) ); Initially, you can use the guts of the ...


2

If you add the image to the HTML like that, you won't get it to tile. In order to get an image to tile is has to be a background image, so you need to add it via a CSS rule. If I understand what you've done, you need to add the height and width to the header class and place your image as a background image on that div. For both of these you need to write ...


2

Yes, this can be done with CSS. I have done this with page and post IDs. IMPORTANT: The following are base examples and will need to be tested and tuned for your use. If you note any error here (with the base CSS examples), please post a note about the error. To ID pages and posts, go to your Pages or Posts page and hover over the name of any page or post....


2

Another solution could be you register a meta box for the project pages which lets you type in whatever class name you want for each page… function add_project_page_metabox() { add_meta_box( 'project_page_meta', // $id 'Project Meta', // $title 'ppm_callback', // $callback 'page', // $...


2

Try to use the the_post_thumbnail_url function: Gets the direct image URL for the featured image of the current post. <div id="<?php echo post_name; ?>" class="page<?php echo $post_id; ?>" style="background: url(<?php echo get_the_post_thumbnail_url( $post_id, 'large' ); ?>) !important;">


2

I assume you would like to end up with something like this: Theme way If you want to put this logic in your template, as you state in your question, there is quite a bit of coding. You need to: create metabox create content (field and description) in that metabox - that's called "callback" in the meta_box docs create logic that saves data from the meta ...


2

In this scenario, the tag that you want to call to execute your function is the wp_head(). Looking at the code you provides, you have the idea down, but I decided to rewrite it differently. In your child theme's functions.php file, add the following: add_action( 'wp_head', 'wpse_238911_weekly_background' ); function wpse_238911_weekly_background() { ...


1

You can not delete or ignore default styling in a child theme. You must override the declaration. .content-ver-sep { background: transparent !important; border-bottom: none !important; clear: both; height: 1px; } this should do the trick -


1

I do not know this theme. But you must use this two functions somewhere: get_theme_mod ('background_image', $default); set_theme_mod ('background_image', $_category_image_absolute_path); Maybe, you can define new modification names with this functions. For example, 'backgroud_image_entertainment', 'background_image_storysode', etc. (as is shown in the ...


1

I have hunted down the problem. It is the _custom_background_cb function in wp-includes/theme.php file. on line 1272 the comment "A default has to be specified in style.css. It will not be printed here." Line 1272 is where the color is being retrieved: $color = get_theme_mod( 'background_color' ); If we change that to: $color = get_theme_mod( '...


1

Place the following code above the DOCTYPE in header.php: <?php $bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' ); // array of filenames $i = rand(0, count($bg)-1); // generate random number size of the array $selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen ?&...


1

Brad Dalton already gave a bit to answer this — add a body class (<body <?php body_class('nameofyourclass'); ?>>). Then the next step is to have a look at the classes WP adds automatically. Those are (in regard to your example): Projects: .page-parent - Project 1: .page-parent and .page-child -- Project 1 Subpage 1 ....


1

There are two parts to the answer: You can set the size of images using add_image_size. This is done in your functions.php. add_image_size( 'background-image', 900, 500 ); //900 px wide 500px high - no crop Once this is set you will need to regenerate your thumbnails. There are number of great plug-ins that can help you with that task. After you add the ...


1

Because my neighborhoods were the only pages that required custom header colors i decided to just include its custom header within the single-neighborhood.php page so that the top header container, that was wrapping the navigation, logo, etc., would reflect the custom color chosen from the custom fields in the admin. It was the only way for the header ...


1

First of all I don't think that create a custom post type only for backgrounds is a right choose: backgrond are images and images already have their post type: attachment. If you have Worpress 3.5+ you can register a custom taxonomy for attachments, call it, e.g. 'image_scope' : register_taxonomy('image_scope', 'attachment', $args ); for the $args array ...


1

If you're using the built in custom background stuff, it's already all using postMessage. So, just bind a function to the background_color message and adjust your border color accordingly. Something like this, I expect: wp.customize('background_color',function( value ) { value.bind(function(to) { jQuery('whatever').css('color', to ? to : '' ); ...


1

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 ( ...


Only top voted, non community-wiki answers of a minimum length are eligible