This is what bothers me.
This is my functions.php:
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array( 'avada-stylesheet','avada- max-2c','avada-min-2c-max-3c','avada-min-3c-max-4c','avada-min-4c-max-5c','avada-min-5c-max-6c','avada-min-768-max-1024-p','avada-min-768-max-1024-l','avada-max-shbp-18','avada-max-shbp-32','avada-max-640','avada-min-768-max-1024-woo' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 );
if ( !function_exists( 'child_theme_configurator_css' ) ):
function child_theme_configurator_css() {
wp_enqueue_style( 'chld_thm_cfg_child', trailingslashit( get_stylesheet_directory_uri() ) . 'style.css', array( 'chld_thm_cfg_parent' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'child_theme_configurator_css', 20 );
// END ENQUEUE PARENT ACTION
An this is my style.css file in my child theme:
/*
Theme Name: Avada Child
Theme URI: http://avada.theme-fusion.com/
Template: Avada
Author: ThemeFusion
Author URI: http://themeforest.net/user/ThemeFusion
Description: The #1 selling theme of all time that allows you to build virtually any design style.
Version: 5.7.2.1545428017
Updated: 2018-12-21 22:33:37
*/
.woocommerce-message {
padding-left: 18px;
background-color: #252a33;
border-top: 1px solid rgba(128,128,128,1);
border-top-color: rgb(128, 128, 128);
border-bottom: 1px solid rgba(128,128,128,1);
border-bottom-color: rgb(128, 128, 128);
color: rgba(128,128,128,1);
}
My goal is to change background-color, but it doesn't work ... I used Child Theme Configurator plugin to make a child theme, and I think that plugin is responsible for that how function.php looks like...
Please help.
Paul
Related
trust y'all good. I have an issue with woocommerce product tab heading(title) not showing. I have tried function.php via a child theme and CSS but none seem working. These I have tried
function.php
add_action( ‘after_setup_theme’, ‘cg_add_desc_tab_title’, 99 );
function cg_add_desc_tab_title() {
remove_filter( ‘woocommerce_product_description_heading’, ‘__return_null’ );
}
CSS.
.panel.woocommerce-Tabs-panel–additional_information h2:first-of-type,
.panel.woocommerce-Tabs-panel–reviews h2:first-of-type {
display: block;
}
Any help is appreciated.
add_action( ‘after_setup_theme’, ‘cg_add_desc_tab_title’, 99 );
function cg_add_desc_tab_title() {
remove_filter( ‘woocommerce_product_description_heading’, ‘__return_null’ );
}
CSS.
.panel.woocommerce-Tabs-panel–additional_information h2:first-of-type,
.panel.woocommerce-Tabs-panel–reviews h2:first-of-type {
display: block;
}
Woocommerce injects the following inline css rule into the head section of my theme. Any idea how to remove it through my child themes functions.php?
<style id='woocommerce-inline-inline-css' type='text/css'>.woocommerce form .form-row .required { visibility: visible; }</style>
If im not missing anything the following code block in the woocommerce plugins file ...woocommerce-includes/class-wc-frontend-scripts.php is responsible for it.
// Placeholder style.
wp_register_style( 'woocommerce-inline', false ); // phpcs:ignore
wp_enqueue_style( 'woocommerce-inline' );
if ( true === wc_string_to_bool( get_option( 'woocommerce_checkout_highlight_required_fields', 'yes' ) ) ) {
wp_add_inline_style( 'woocommerce-inline', '.woocommerce form .form-row .required { visibility: visible; }' );
} else {
wp_add_inline_style( 'woocommerce-inline', '.woocommerce form .form-row .required { visibility: hidden; }' );
}
The following action removes
<style id='woocommerce-inline-inline-css' type='text/css'>.woocommerce form .form-row .required { visibility: visible; }</style>
from the head section. Code goes into your functions.php file of your child or parent theme.
Input from O. Jones in the comments: Or, consider using the Code Snippets plugin to hold these small tweaks to a site. If you edit functions.php you may (a) have it overwritten by an update, (b) possibly lose track of where you put your tweaks.
// Remove the following from head section - see source code
// <style id='woocommerce-inline-inline-css' type='text/css'>.woocommerce form .form-row .required { visibility: visible; }</style>
add_action('wp_enqueue_scripts', 'remove_woo_inline_css_head_ac',11);
function remove_woo_inline_css_head_ac() {
wp_deregister_style( 'woocommerce-inline' );
}
Just add // before function to comment that line
This is the code correctly:
// Placeholder style.
wp_register_style( 'woocommerce-inline', false ); // phpcs:ignore
wp_enqueue_style( 'woocommerce-inline' );
if ( true === wc_string_to_bool( get_option( 'woocommerce_checkout_highlight_required_fields', 'yes' ) ) ) {
//wp_add_inline_style( 'woocommerce-inline', '.woocommerce form .form-row .required { visibility: visible; }' );
} else {
//wp_add_inline_style( 'woocommerce-inline', '.woocommerce form .form-row .required { visibility: hidden; }' );
}
I have a Wordpress website where the child theme is activated. It seems that everything is working fine, except the stylesheet. The CSS file isn't included.
In function.php file in the child theme:
function enqueue_child_styles() {
wp_enqueue_style('child-theme', get_stylesheet_directory_uri() .'/style.css', array('parent-theme'));
}
add_action('wp_enqueue_scripts', 'enqueue_child_styles');
The style.css file is in the root folder of the child theme:
But the styles aren't reflected on my website itself.
My child theme CSS:
/*
Theme Name: Vitrine Child
Theme URI: http://themeforest.net/user/Epicomedia
Template: vitrine
Author: EpicoMedia
Author URI: http://www.Epicomedia.com
Description: WooCommerce WordPress Theme
Tags: two-columns,three-columns,left-sidebar,right-sidebar,custom-background,custom-header,custom-menu,editor-style,featured-images,flexible-header,full-width-template,microformats,post-formats,sticky-post,theme-options,translation-ready,accessibility-ready
Version: 1.0.1498974811
Updated: 2017-07-02 05:53:31
*/
/* Write your styles here */
/* Cookiebot */
a#CybotCookiebotDialogBodyLevelButtonAccept {
background: #E5002F !important;
border: none !important;
}
/* WPCF7 form submit button */
.wpcf7-form-control.wpcf7-submit {
border-color: black;
color: black;
}
function.php in child theme:
<?php
require_once dirname( __FILE__ ) . '/widgets/bln-widget-functions.php';
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
function example_enqueue_styles() {
// enqueue child styles
wp_enqueue_style('child-theme', get_stylesheet_directory_uri() .'/style.css', array('parent-theme'));
}
add_action('wp_enqueue_scripts', 'example_enqueue_styles');
Have a look through the Codex: https://codex.wordpress.org/Child_Themes
Your style.css in your child theme needs a specific comment header:
The exmaple in the Codex is:
/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentyfifteen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/
A couple things to note:
You will need to replace the example text with the details relevant to your theme.
The Template line corresponds to the directory name of the parent theme.
The parent theme in the example is the Twenty Fifteen theme, so the Template will be twentyfifteen. You're probably working with a different theme, so adjust accordingly.
UPDATE:
enqueue both parent and child theme (only need child css if you have css in it):
Just Parent:
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>
Parent and Child:
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
I've searched through several questions and still having trouble. I'd really appreciate some expertise from y'all. =)
The child theme created and activated on my WordPress site seems to be enacting no changes.
I know essentially zero PHP but trying to use the functions.php instead of #import since it's supposed to be a better load time.
Here's what I have in my child theme's directory style.css (first) and functions.php (second)
/*
Theme Name: Quest-Child
Description: No Coward's Quest Child Theme
Author: Jason from No Coward
Author URI: http://www.nocoward.com
Template: quest
Version: 1.0
*/
/* add padding to site description */
.site-description {
padding-top: 15px;
padding-bottom: 30px;
}
.body {
background: red;
}
/* can be found on "Services" page. Is the first ID within the <p> element */
#cc-m-12571703896 {
background: blue;
}
<?php
function my_theme_enqueue_styles() {
$parent_style = 'quest-all-css'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
WordPress recognizes the child theme and has allowed me to activate it successfully.
The stuff in CSS is what I've tried to use for testing my child-theme laying down my changes. Nothing is appearing.
Again, I have zero PHP knowledge. Based on the official WordPress "How to create a child theme", I copied and pasted the code above and tried to fill in the "parent-style" value based on their instructions.
Here's what I saw on my parent theme I could possibly be using for the functions.php "parent-style"...
// Enqueue required styles
wp_enqueue_style( 'quest-bootstrap', get_template_directory_uri() . '/assets/plugins/bootstrap/css/bootstrap.min.css' );
wp_enqueue_style( 'smartmenus', get_template_directory_uri() . '/assets/plugins/smartmenus/addons/bootstrap/jquery.smartmenus.bootstrap.css' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/plugins/font-awesome/css/font-awesome.min.css' );
wp_enqueue_style( 'animate-css', get_template_directory_uri() . '/assets/plugins/animate/animate.css' );
wp_enqueue_style( 'slit-slider', get_template_directory_uri() . '/assets/plugins/FullscreenSlitSlider/css/style.css' );
wp_enqueue_style( 'colorbox', get_template_directory_uri() . '/assets/plugins/colorbox/colorbox.css' );
wp_enqueue_style( 'Quest-style', get_stylesheet_uri(), array(
'quest-bootstrap',
'smartmenus',
'font-awesome',
'animate-css',
'slit-slider',
'colorbox'
) );
...
// Enqueue required styles
wp_enqueue_style( 'quest-all-css', get_template_directory_uri() . '/assets/css/plugins-all.min.css' );
wp_enqueue_style( 'Quest-style', get_stylesheet_uri(), array( 'quest-all-css' ) );
// Enqueue required scripts
wp_enqueue_script( 'quest-all-js', get_template_directory_uri() . '/assets/js/quest-and-plugins.js', array(
'jquery',
'masonry'
) );
What am I missing?
Thanks in advance!
-Jason
I managed to fix this. Here's the PHP code I found on the help forum. I think the "Portfolio" bit may be extraneous, but it's working so I'm leaving it there just in case.
<?php
add_action( 'wp_enqueue_scripts', 'quest_child_enqueue_styles' );
function quest_child_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_filter( 'quest_plus_template_content-portfolio', 'quest_child_template_portfolio' );
function quest_child_template_portfolio(){
return get_stylesheet_directory() . '/content-portfolio.php';
}
Caveat to this solution: There is a weird thing happening. I put in some styling to make something "Background: red" so I could test if the child theme was working, and despite deleting that bit of code, it is still appearing.
For now I'm chalking it up to slow hosting but be aware that's happening if you follow this solution.
Hope this helps someone else! =)
Jason
I'm trying to create a Wordpress child theme, but I can't seem to get it to override styles in the parent theme.
functions.php
<?php
if ( ! function_exists( 'my_theme_enqueue_styles' ) ) {
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
}
/**
* WP Enqueue Stylesheets
*/
if ( ! function_exists( 'rev_cust_enqueue_stylesheets' ) ) {
add_action( 'wp_enqueue_scripts', 'rev_cust_enqueue_stylesheets' );
function rev_cust_enqueue_stylesheets() {
wp_enqueue_style( 'rev-main', get_template_directory_uri() . '/layout/css/rev_main.css', array(), '', 'all' );
}
}
?>
rev_main.css
#header .top-header .header-navigation ul li {
margin-left: 40px;
line-height: 1.375;
font-weight: normal !important;
font-size: 1px;
color: #fff;
text-transform: uppercase;
position: relative;
float: left;
}
Why isn't my style class not being picked?
Thank you all in advance.
UPDATE
I don't think the css file even gets picked up,
I have the child theme enabled.
The problem was at:
get_template_directory_uri()
in:
/**
* WP Enqueue Stylesheets
*/
if ( ! function_exists( 'rev_cust_enqueue_stylesheets' ) ) {
add_action( 'wp_enqueue_scripts', 'rev_cust_enqueue_stylesheets' );
function rev_cust_enqueue_stylesheets() {
wp_enqueue_style( 'rev-main', get_template_directory_uri() . '/layout/css/rev_main.css', array(), '', 'all' );
}
}
?>
This points to the parent theme, instead of the child theme.
It should be get_stylesheet_directory_uri as follows:
function rev_cust_enqueue_stylesheets() {
wp_enqueue_style( 'rev-main', get_stylesheet_directory_uri() . '/layout/css/rev_main.css', array(), '', 'all' );
}