Product tab heading not showing - php

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;
}

Related

"hide" element when if-statement is true (similar to if > then)

I have this code that adds a custom field to my products in woocommerce:
add_action( 'woocommerce_single_product_summary', 'shoptimizer_custom_author_field', 3 );
function shoptimizer_custom_author_field() { ?>
<?php if(get_field('author')) { ?>
<div class="cg-author"><?php the_field('author'); ?></div>
<?php }
}
Now I would want to add a condition to the if-statement that says "if field is not empty, hide product title".
The class for the product page product title seems to be "product_title".
Will be fascinating how this will look like once It's added into this piece of code above. I think it's not a big deal, but my comprehension ends with HTML and CSS sadly.
I'm not sure if I understand your question correctly, but if you want to hide the product title if the custom field is not empty, you can use the following code:
add_action('woocommerce_single_product_summary', 'shoptimizer_custom_author_field', 3);
function shoptimizer_custom_author_field() {
if (get_field('author')) {
echo '<style>.product_title { display: none; }</style>';
}
}
If you want to hide the product title if the custom field is empty, you can use the following code:
add_action('woocommerce_single_product_summary', 'shoptimizer_custom_author_field', 3);
function shoptimizer_custom_author_field() {
if ( ! get_field('author')) {
echo '<style>.product_title { display: none; }</style>';
}
}
Just to conclude this thread, below anybody that seeks a similar answer can copy and paste the solution that worked for me:
add_action( 'wp_head', function() {
?><style>
h1.product_title.entry-title {
display: none;
}
.cg-title h1.product_title.entry-title {
display: block !important;
}
}</style><?php
} );
add_action( 'woocommerce_single_product_summary', 'shoptimizer_custom_author_field', 3 );
function shoptimizer_custom_author_field() { ?>
<?php if(get_field('author')) { ?>
<div class="cg-author"><h1><?php the_field('author'); ?></h1></div>
<?php }
else {?>
<div class="cg-title"><?php woocommerce_template_single_title(); ?> </div>
<?php
}
}

Remove Inline Css Rules injected through Woocommerce into Head Section (woocommerce-inline-inline-css)

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; }' );
}

How to override parent style.css in woocommerce? Function.php file problem

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

Hide woocommerce storefront handheld footer on cart, checkout, and account

I am trying to hide the Storefront handheld footer bar on the cart, footer, and account pages. I am new to coding in Wordpress and Woocommerce and coded the following and nothing works. Below are my 3 attempts what am I doing wrong? Any assistance will be greatly appreciated.
add_action('wp_head','noshowHHFCSS');
function noshowHHFCSS() {
echo '<style>
/* Do not show hand held footer bar on cart, check out and account page*/
.page-id-5 .page-id-6 .page-id-7 .storefront-handheld-footer-bar {
display: none!important;
}
</style>';
}
if ( is_cart() || is_checkout() || is_account_page() ) {
echo '<style>
/* Do not show hand held footer bar on cart, check out and account page*/
.storefront-handheld-footer-bar {
display: none!important;
}
</style>';
}
add_action( 'init', 'jk_remove_storefront_handheld_footer_bar' );
if ( is_cart() || is_checkout() || is_account_page() ) {
function jk_remove_storefront_handheld_footer_bar() {
remove_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
}
}
You can try something like this:
Create in your root theme folder a new folder called CSS if you don't have one already. After that create a customFooterStyle.css file with your footer style code in it.
In the function.php place this code:
function footerBarStyle() {
wp_enqueue_style( 'custom_footer_css', get_template_directory_uri() . '/css/customFooterStyle.css' );
}
if(is_cart() || is_checkout() || is_account_page() ){
add_action('wp_enqueue_scripts', 'footerBarStyle');
}

Remove CSS of WordPress admin bar

In a WordPress blog I want to disable admin/logged users topbar.
add_action('get_header', 'remove_admin_login_header');
function remove_admin_login_header() {
remove_action('wp_head', '_admin_bar_bump_cb');
}
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
show_admin_bar(false);
}
The code above removes the admin bar but it still prints the following CSS and I need to remove it because it is useless.
<style type='text/css'>#wp-admin-bar-ai-toolbar-settings .ab-icon:before{content:'\f111';top:2px;color:rgba(240,245,250,.6)!important;}#wp-admin-bar-ai-toolbar-settings-default .ab-icon:before{top:0px;}#wp-admin-bar-ai-toolbar-settings .ab-icon.on:before{color:#00f200!important;}#wp-admin-bar-ai-toolbar-settings-default li,#wp-admin-bar-ai-toolbar-settings-default a,#wp-admin-bar-ai-toolbar-settings-default li:hover,#wp-admin-bar-ai-toolbar-settings-default a:hover{border:1px solid transparent;}#wp-admin-bar-ai-toolbar-blocks .ab-icon:before{content:'\f135';}#wp-admin-bar-ai-toolbar-positions .ab-icon:before{content:'\f207';}#wp-admin-bar-ai-toolbar-positions-default .ab-icon:before{content:'\f522';}#wp-admin-bar-ai-toolbar-tags .ab-icon:before{content:'\f475';}#wp-admin-bar-ai-toolbar-no-insertion .ab-icon:before{content:'\f214';}#wp-admin-bar-ai-toolbar-ad-blocking .ab-icon:before{content:'\f160';}#wp-admin-bar-ai-toolbar-processing .ab-icon:before{content:'\f464';}#wp-admin-bar-ai-toolbar-positions span.up-icon{padding-top:2px;}#wp-admin-bar-ai-toolbar-positions .up-icon:before{font:400 20px/1 dashicons;}</style>
What PHP code or filter would you use to remove it?
NOTE: I want to remove CSS output, not hiding divs!
Try this, to remove that inline css. Copy this to your functions.php
add_action('get_header', 'remove_admin_login_header');
function remove_admin_login_header() {
remove_action('wp_head', '_admin_bar_bump_cb');
}
if (!function_exists('disableAdminBar')) {
function disableAdminBar(){
remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); // for the admin page
remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // for the front end
function remove_admin_bar_style_backend() { // css override for the admin page
echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
}
add_filter('admin_head','remove_admin_bar_style_backend');
function remove_admin_bar_style_frontend() { // css override for the frontend
echo '<style type="text/css" media="screen">
html { margin-top: 0px !important; }
* html body { margin-top: 0px !important; }
</style>';
}
add_filter('wp_head','remove_admin_bar_style_frontend', 99);
}
}
// add_filter('admin_head','remove_admin_bar_style_backend'); // Original version
add_action('init','disableAdminBar'); // New version
//JUST PAST THIS function.php

Categories