Header php background color

srikat / functions.php

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

( function ( $ )
«use strict» ;
// Header Background Color — Color Control
wp . customize ( ‘header_background_color_setting’ , function ( value )
value . bind ( function ( to )
$ ( ‘.site-header’ ) . css ( ‘backgroundColor’ , to ) ;
> ) ;
> ) ;
// Header Background Image — Image Control
wp . customize ( ‘header_background_image_setting’ , function ( value )
value . bind ( function ( to )
$ ( ‘.site-header’ ) . css ( ‘background-image’ , ‘url( ‘ + to + ‘)’ ) ;
> ) ;
> ) ;
// Header Background Image Repeat — Checkbox
wp . customize ( ‘header_background_image_repeat_setting’ , function ( value )
value . bind ( function ( to )
$ ( ‘.site-header’ ) . css ( ‘background-repeat’ , true === to ? ‘repeat’ : ‘no-repeat’ ) ;
> ) ;
> ) ;
// Header Background Image Size — Checkbox
wp . customize ( ‘header_background_image_size_setting’ , function ( value )
value . bind ( function ( to )
$ ( ‘.site-header’ ) . css ( ‘background-size’ , true === to ? ‘cover’ : ‘auto auto’ ) ;
> ) ;
> ) ;
> ) ( jQuery ) ;

Источник

css — Change background color of a PHP include on different pages?

We are making a website for a school project and we help with some (simple) PHP.

We got a website with 4 pages, we are using includes for the header/navigation. But we want different background colors for our pages, but if we change the color, the color is going to be changed on all the sites because we use includes.

This is an example of a page:

 ###SOME CONTENT FOR THIS PAGE### 

We want to change the color of the < body >tag which is inside in «includes/header.inc.php»

But as I said if we change that color, the color is changed on all the pages where we use the header include.

Is it possible to change this with some PHP?

Our navigation is pretty simple it can bee seen here:

  

Please write if you need any more information in order to help us or if you dont understand our problem. Thanks in advance!

Answer

Solution:

You can set the color on each PHP file before you include the header. Then you can use that PHP variable in css in the header.inc.php

 ###SOME CONTENT FOR THIS PAGE### 

If the css is between your header tag you can do something like this in your css:

If it isn’t you could use the style attribute, e.g.:

Answer

Solution:

header.inc.php

Answer

Solution:

you can change the background color in the HTML code of each of your pages using tags:

Share solution ↓

Additional Information:

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Similar questions

Find the answer in similar questions on our website.

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

About the technologies asked in this question

PHP

PHP (from the English Hypertext Preprocessor — hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/

CSS

CSS (Cascading Style Sheets) is a formal language for describing the appearance of a document written using a markup language. It is mainly used as a means of describing, decorating the appearance of web pages written using HTML and XHTML markup languages, but can also be applied to any XML documents, such as SVG or XUL.
https://www.w3.org/TR/CSS/#css

HTML

HTML (English «hyper text markup language» — hypertext markup language) is a special markup language that is used to create sites on the Internet. Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/

Welcome to programmierfrage.com

programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.

Get answers to specific questions

Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.

Help Others Solve Their Issues

Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.

Источник

How to change the background color of my header dynamically based on a Custom Posts types color value?

I’ve been able to figure out how to include the custom field i’m referencing within an inline style within a div that wraps my header. The problem is that it’s in my header and so when a particular Post is called, to display in the body, that has the custom field of color picker and a certain color (say #567263) has been entered from the admin for that post it won’t appear because it has no reference to the permalink that was clicked to get to that page. Here in lies a new lesson for me to learn in WP. And i’m not sure if it’s conditions, functions, etc. I can call a custom post type from within my header like i did here: (this is my custom header for neighborhood pages)

 'neighborhood', 'posts_per_page' => 1, ); $the_query = new WP_Query( $args ); ?> have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> ">    

But it only calls on the «bg_clr» custom field of the last post i created. So i have 27 neighborhoods i’ve created each with a custom color for their background but the_field(); only captures the hex/color value of the last neighborhood post created. What could be a good solution to this? I thought about adding this div into the single-neighborhood.php file but it wraps the header so that wouldn’t be possible. I could also include the header php code itself within this particular template, that could be a solution but i want to keep my header separate and push myself to learn something new so i’d rather learn another approach. Any takers? Thanks.

Источник

Читайте также:  Website layout css templates
Оцените статью