Need help creating child theme for Arcade Basic
-
I’ve got 3 .css files in my parent theme… style.css, editor-style.css, & rtl.css. I created the child theme files for style.css and functions.php and enqueued the style sheet in the functions.php file as shown below:
<?php
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘child-style’, get_stylesheet_uri(), array( ‘parent-style’ ) );
}None of the pages or menu info that I created is showing up on the site though, only the out of the box info. I am assuming I need to enqueue the other two style sheets over, correct? If so, how do I do that? Do I create 2 new files like I did for the style.css file and then add identical enqueue code in the functions.php file and replace .css filename to the corresponding .css files? – Thank you!
-
Update: So several hours later the pages I created started appearing in the child theme, and then a couple more hours later the main menu & page header images started appearing. The changes I had made in the theme’s customizer did not appear though, I had to go in there and redo those. I am assuming that is because I did not create a customizer.php file in the child theme?? Not sure why the pages and menu started showing up in increments several hours apart though, odd! I even cleared my cache immediately after creating the child theme and that did not seem to help…
There are several other .php files I will be making edits to in the near future, eg: the footer.php, frontpage.php, image.php etc… and possibly another .css file (editor-style.css). If I understand correctly, all changes I will be making to these files I will be entered into the child theme’s function.php file, correct? But before I do that, I need to create files in the child theme for each of the files I am editing and on top of that, in the functions.php file I need to enqueue them, correct?
If thats the case, what enqueue code do I need to enter into the functions.php file? The same code I used for the style.css file or will it vary depending on each file? I am brand new to wordpress and although I understand the concept of the child theme and enqueue code, I am clueless as to what exactly I need to add for each extra file.
I would also like to create files for individual page changes as well so I can make changes to any particular page instead of site wide. How would I go about doing that?
Thanks so much in advance for you help!
The changes I had made in the theme’s customizer did not appear though, I had to go in there and redo those. I am assuming that is because I did not create a customizer.php file in the child theme??
No, it’s because any changes made in the Customizer only apply to that particular theme, and since WordPress considers a child theme to be a separate theme from the parent theme, the customizations won’t apply to it. This is the same reason why you’ll likely have to reassign any navigation menus and sidebar widgets when you switch to a child theme.
If I understand correctly, all changes I will be making to these files I will be entered into the child theme’s function.php file, correct? But before I do that, I need to create files in the child theme for each of the files I am editing and on top of that, in the functions.php file I need to enqueue them, correct?
No, you only need to enqueue stylesheets in
functions.php. So you will need to enqueueeditor-style.cssby usingadd_editor_style(), but if you want to make changes to the PHP files, you simply need to copy them into your child theme’s folder and edit that copy. WordPress will use the PHP files in your child theme first and use the parent theme’s PHP files only as a last resort.I would also like to create files for individual page changes as well so I can make changes to any particular page instead of site wide. How would I go about doing that?
You could make separate page templates, or you could use some custom CSS, depending on what you’re trying to do. If you need more help with that, it’s best to make a separate topic and post a link to your site, as well.
@stephencottontail Thank you very much!!
Oh wait, Im a little confused… so to enqueue editor-style.css, do I need to add the entire snippet of code like I did for the style.css
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘child-style’, get_stylesheet_uri(), array( ‘parent-style’ ) );
}and replace
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
with
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/editor-style.css’ );
directly underneath the style.css enqueue snippet on the .php?
And then just to clarify, for any .php file I want to edit, i need to make a new identical file in the child theme, copy and paste the entire code over and make my changes there or just the snippets of code I am wanting to change? Thanks again! Sorry for additional questions. So simple yet so foreign when you have never done it before 🙂
Oh wait, Im a little confused… so to enqueue editor-style.css, do I need to add the entire snippet of code like I did for the style.css
No, you should use WordPress’ built-in specialty function to enqueue your editor stylesheet. In your child theme’s
functions.php, add this code at the endfunction my_theme_add_editor_styles() { add_editor_style( 'editor-style.css' ); } add_action( 'after_setup_theme', 'my_theme_add_editor_styles' );And then just to clarify, for any .php file I want to edit, i need to make a new identical file in the child theme, copy and paste the entire code over and make my changes there or just the snippets of code I am wanting to change?
You need to copy and paste the entire code from the parent theme’s version of the file and then edit the parts you need to change. WordPress won’t use the parent theme’s version of the file at all, so if you don’t have all the required code in the child theme’s version, something probably won’t look right.
I didnt know they had a built in specialty function. Where’s it at? I just searched on here for it and found an article that gave some hook examples but Im not sure if thats what I need to use, this looks like it might be correct except the header on my editor-style.css file has really limited info. It says its only used to style the TinyMCE editor. The TinyMCE editor is the html editor on in the wordpress admin correct? And this is basically to add extra features to use in the there only, nothing to do with the front end of my website (well other than what will appear on there from using the html editor…)
Example Hook:
/**
* Proper way to enqueue scripts and styles
*/
function theme_name_scripts() {
wp_enqueue_style( ‘style-name’, get_stylesheet_uri() );
wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(), ‘1.0.0’, true );
}add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ );
editor-style.css
/*
Theme Name: Arcade
Description: Used to style the TinyMCE editor.
*//* =Import Google Fonts
————————————————————– */
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700|Railway);/* =Normalize.css v2.1.3 | MIT License | git.io/normalize
————————————————————– */haha… I tried to use the block quotes, fail!
You can use the code I provided to properly enqueue your editor stylesheet:
function my_theme_add_editor_styles() { add_editor_style( 'editor-style.css' ); } add_action( 'after_setup_theme', 'my_theme_add_editor_styles' );That snippet of code should be added to the end of your child theme’s
functions.php, right after this snippet (from your original post):<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'parent-style' ) ); }The TinyMCE editor is the html editor on in the wordpress admin correct?
Yes.
And this is basically to add extra features to use in the there only, nothing to do with the front end of my website
Not really, no. All this does is change how the HTML editor looks. If you’d like to add features to the HTML editor, you should try a plugin instead: https://wordpress.org/plugins/tinymce-advanced/
Ok, I think I confidently understand. Thanks so much for you patience and answers!
The topic ‘Need help creating child theme for Arcade Basic’ is closed to new replies.