Best Premium and Free WordPress Themes › Forums › Corporate Plus › Child Theme Hooks Folder
- This topic has 3 replies, 3 voices, and was last updated 8 years ago by acmethemes.
-
AuthorPosts
-
June 9, 2016 at 4:16 pm #5646sidfilmzMember
Hi, I’ve seen this question addressed, but only in a forum link that I cannot access to reply to (http://www.acmethemes.com/supports/topic/child-theme-help/).
I created a Child Theme in order to edit the ‘header.php’ file(s), but when I copy the “acmethemes/hooks” folder into my child theme and make edits, the edits do not show. I added an additional widget to that file, and it is available to edit from the Dashboard, but does not show on the Live Site. When I add the widget to the “acmethemes/hooks/header.php” file in the parent theme, it does show up. However, that still leaves it susceptible to being deleted on the next theme update.
In my Child Theme ‘functions.php’ file I added:
function new_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Header Widget' ), 'id' => 'header-widget', 'description' => '', 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2><div class="line"><span></span></div>', ) ); } add_action( 'widgets_init', 'new_widgets_init' );
In the “acmethemes/hooks/header.php” file I added:
<?php dynamic_sidebar( 'header-widget' ); ?>
The widget only shows on the frontend if I add it to the Parent Theme files, not the Child Themes. Any help would be greatly appreciated, thank you!
June 10, 2016 at 5:47 am #5649acmethemesKeymasterHello sidfilmz,
Thank you so much for using our theme and thanks for your questions too. We only provide access to the premium theme support for our premium users. We know that you have a better knowledge about WordPress codes and child themes.
While editing the parent theme from child theme, you have to make the folder structure same as parent theme on the child theme.
1. Create a child theme. (You already have it)
2. Make the same directory path as parent theme on child theme.
Example: If you want to edit the file which is inside theacmethemes/hook/header.php
make the same directory path on child theme.acmethemes/hook/header.php
No need to add the the files inside the directory, just put the file which you are going to edit.
3. If you need to edit some other files, please follow the same process on 2.We tested create a child theme and test Corporate Plus theme and it is working fine here. Please check once that you create a functional child theme.
If you have any confusion on, please let us know. We will provide the best solutions for you.
Warm Regards,
Acme SupportsJune 10, 2016 at 5:00 pm #5648sidfilmzMemberI did exactly as suggested, if you read my previous post. I copied the file & folder structure as ‘acmethemes/hooks/header.php’ into my Child Theme. The Child Theme is working if I override files such as footer.php, page.php, etc. — BUT when trying to override any files in the ‘acmethemes/hooks’ folder, it is not working.
I even copied ‘acmethemes/init.php’ over to my Child Theme to change:
require_once get_template_directory() . '/acmethemes/hooks/header.php';
to:
require_once get_stylesheet_directory() . '/acmethemes/hooks/header.php';
hoping to force the child theme to load that file from the child and not the parent, but it still does not.
My child theme function.php in it’s entirety:
<?php // Exit if accessed directly if ( !defined( 'ABSPATH' ) ) exit; // BEGIN ENQUEUE PARENT ACTION 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( 'bootstrap','fontawesome','jquery-bxslider' ) ); } endif; add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 ); // END ENQUEUE PARENT ACTION function new_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Header Widget' ), 'id' => 'header-widget', 'description' => '', 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2><div class="line"><span></span></div>', ) ); } add_action( 'widgets_init', 'new_widgets_init' );
I have even tried both the following when trying to register the Widget, but I don’t think this is this issue:
'name' => esc_html__( 'Header Widget', 'corporate-plus' ),
'name' => esc_html__( 'Header Widget', 'corporate-plus-child' ),
and Child style.css begins with:
/* Theme Name: Corporate Plus Child Theme URI: http://www.acmethemes.com/themes/corporate-plus Template: corporate-plus Author: acmethemes Author URI: http://www.acmethemes.com/ Version: 1.2.1.1465336348 Updated: 2016-06-07 21:52:28 */
June 11, 2016 at 4:41 am #5647acmethemesKeymasterHello sidfilmz,
Your child theme style.css is fine.
By seeing your code it seems like there must be sidebar present that you have added, in the back-end.
But for appearing sidebar( widgets) at the front-end, overriding templates files will work but doesn’t work for hooks files and folder( however it will work on pro version http://www.acmethemes.com/themes/corporate-plus-pro/ ),for the hooks file you need to remove_action of parent theme, then add child theme action by add_action.
( The solution given by Acme Supports will work on Pro version only, because in pro version you can even override each and every folder and files inside acmethemes/ folder expect init.php ).
Please use remove_action and add_action for removing hooks and adding hooks for now.Best Regards,
Acme Themes -
AuthorPosts
- The topic ‘Child Theme Hooks Folder’ is closed to new replies.