Removing Widgets From Child Theme - wordpress

I've created a Wordpress child theme and now want to remove the widgets from the sidebar. However all the tutorials are not helping.
Each one says to add the following code to my functions.php file in my child theme:
<?php
function unregister_old_sidebars() {
unregister_sidebar('sidebar-1');
}
add_action( 'widgets_init', 'unregister_old_sidebars' );
?>
However, do I copy the entire functions file from the parent theme and copy it in a new functions.php in my child theme, or is this the ONLY code that I put into my child theme functions.php file.
Nothing I do seems to be working.

Related

How properly enqueue a child theme

I've been trying to develop a simple child theme to tweak a few things on my website which currently uses the vantage theme. So far, I've had little success.
The two files (style.css and function.php) I've created only have a few lines of code, but I'm still unable to pinpoint the problem.
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles',
PHP_INT_MAX);
function enqueue_child_theme_styles() {
wp_enqueue_style( 'parent-style',
get_template_directory_uri().'/style.css' );
}
?>
/*
Theme Name: vantage-child
Template: Vantage
*/
body {
color:aqua;
}
I suspect the problem is with the enqueueing in the PHP file, but all configurations that I have found on the internet and the wordpress codex don't seem to work on my site. When I activate the child theme created by my code, the site reverts to ONLY the styles in my child theme's stylesheet, instead of falling back on the parent theme's stylesheet when no styles are specified in the child theme.
For child theme you can first need to create folder with themename-child.
Then you have to create style.css file.
Put the following lines in your style.css
/*
Theme Name: Twenty Fourteen Child
Theme URI: http://yourwebsite.com/twentyfourteen-child/
Description: My first child theme, based on Twenty Fourteen
Author: Joshi Niket
Template: twentyfourteen
Text Domain: twenty-fourteen-child
*/
Then create functions.php in child theme folder and put the following code.
<?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' );
}
?>
Please check following link to make child theme with proper steps, i have added few here to guid you.ReferenceLink
Thank you ,I hope this helps you.
Please install and create child theme by using One-Click Child Theme
plugin. This is very easy to use

WordPress: Unable to overwrite parent theme file via child theme

I'm having issue in overwriting parent theme file via child theme. Normally I copy parent theme file to child theme by following same file structure/path and it works. But this time it is not working. I'm not sure, what is the problem...
The parent file is located at:
wp-content/themes/THEMENAME/assets/js/FILENAME.js
and I put at this path in child theme:
wp-content/themes/CHILDTHEME/assets/js/FILENAME.js
Same problem on this file:
Parent Path:
wp-content/themes/THEMENAME/includes/FILE.php
Child Path:
wp-content/themes/CHILDTHEME/includes/FILE.php
I'm pretty sure, I'm missing something technical but I'm unable to figure out. Looking for help!
Child theme doesn't override css/js files, to achieve that, You will need to dequeue these scripts in the child functions.php file, You need to get the script handle name that parent theme uses to enqueue it.
add_action( 'wp_enqueue_scripts', function(){
wp_dequeue_script( 'script-handle-name' );
}, PHP_INT_MAX );
Child theme only overrides the template files Template Hirarchy
To override a php file, There are two conditions:
1) If the file function you want to override is hooked to action / filter then create a function in the child theme functions.php file with a different name and hook it with a higher priority.
2) If you want to override the function itself, you can recreate the function in the child theme functions.php with the same name only if The function is created in the parent theme with the condition.
if ( ! function_exists ( 'my_function' ) ) {
function my_function() {
}
}
otherwise, It will raise a fatal error.

Is there a way to 'dequeue' a `require_once` entry?

I am currently working on a WordPress website, which has a Parent and Child Theme.
The Parent Theme is outputting the following statement, at the top of the WordPress Dashboard:
This theme requires the following plugins: Plugin A, Plugin B, Plugin C etc
Triggering this output, is the following code, within the Parent Theme's functions.php file:
require_once get_template_directory() . '/inc/plugins/class-tgm-plugin-activation.php';
Is there a way I could disable this, via the Child Theme's functions.php? Sure, I could comment it out within the Parent Theme, but this could get overridden during a future update. I did try to copy the entry, into the Child Theme's functions.php, then comment it out there, but that did not work.
Latest Effort
I went into the WordPress Dashboard, where I copied the notification message prefix:
This theme requires the following plugins:
I then went into the file located within get_template_directory() . '/inc/plugins/class-tgm-plugin-activation.php', where I found the above notification prefix, located within the do_action( 'tgmpa_register' ); function.
I then located the add_action for the do_action( 'tgmpa_register' ); within the /inc/functions/tgm-functions.php directory.
I then headed into the Child Theme, and duplicated the above folder hierarchy.
I then commented out both add_action and do_action, within their respective files as well as entering remove_action( 'tgmpa_register', 'register_required_plugins', 999 ); into the Child's functions.php file.
Unfortunately, neither of the above work. I take it, that this is because the Parent Directory parent_theme/inc has priority over the Child Directory child_theme/inc? If so, is there a way to change this?

Customize Enfold theme on my WP site

I've to customize the header in Enfold theme of my WP site. I placed the company logo to the left and under this I placed the primary menu. I need to add another image near to the company logo. I 'created' a theme child and I would like to add a widget to place image on the right of the company logo but the theme expected in the header the company logo and the primary menu only. Can I customize my header to do this? Can you help me please? Thank's!
If you have purchased the enfold theme, you will get the child theme along with that. Your header part (menu and logo) is running from helper-main-menu.php file which is located at enfold/includes/helper-main-menu.php
Now to get this in child theme add the header.php to your child theme and then add a folder named includes and keep a copy of helper-main-menu.php. This should be as same as in parent theme.
Now you can edit your child theme files and add as many widgets you need.
I have tested and it worked for me.Happy Coding :)
I have noticed that your theme is from themeforest so you should create a child theme, then copy your header.php in child theme folder. Then make changes on that file.
For creating a child theme, make a folder inside your 'themes' folder with you child theme name. Now the child theme should have a style sheet in it which is a must. So add a style sheet and the beginning of the child theme style sheet should be as follows:
/*
Theme Name: (theme name) Child
Theme URI: (give URL)
Description: (give description)
Version: (give your version)
Author: (author name)
Author URI: (give URL)
Template: (name of parent theme)
*/
Of these the very important thing is the 'Template' which is the parent theme name. To avoid confusion take the name of parent theme from the parent theme style sheet.
Now the second thing is the functions of your child theme. Just add a php file with the name functions.php and place the below code.
<?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' );
}
?>
This code is for enqueuing the parent theme styles. Here you go! your child theme will work now.

Child theme not including template files of the parent in WordPress

I am creating a child theme , but my child theme in WordPress not including template files of Parent theme. I have read that all the files which are not included in Child theme are automatically imported Child theme But after activating child theme The website is displaying only header, footer and menus but not any page templates and content. Am I forgetting any step or Do I have to add some code or additional files. I am new to Wordpress.
For creating a child theme, make a folder inside your 'themes' folder with you child theme name. Now the child theme should have a style sheet in it which is a must. So add a style sheet and the beginning of the child theme style sheet should be as follows:
/*
Theme Name: (theme name) Child
Theme URI: (give URL)
Description: (give description)
Version: (give your version)
Author: (author name)
Author URI: (give URL)
Template: (name of parent theme)
*/
Of these the very important thing is the 'Template' which is the parent theme name. To avoid confusion take the name of parent theme from the parent theme style sheet.
Now the second thing is the functions of your child theme. Just add a php file with the name functions.php and place the below code
<?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' );
}
?>
This code is for enqueuing the parent theme styles.
Here you go! your child theme will work now. It worked for me.

Resources