I am using Splash theme from StylemixThemes. I am trying to create a child theme in order to edit some things but when I am activating it I do not get the same result as the parent theme.
Inside the child theme folder I have the style.css and the functions.php. Here is the functions.php code
<?php
add_action('wp_enqueue_scripts', 'enqueue_parent_theme_styles'); function enqueue_parent_theme_styles() {
wp_enqueue_style('parent-style', get_template_directory_uri().'/style.css'); }
I am attaching a screenshot for both parent and child theme to show the difference.
parent
child
I am wondering if there is a solution or if there is something I am missing.
Thanks in advance!
You can create your custom child theme learning from wpbeginner.com
Related
I'm confused on how to run my custom shortcode in my child theme. To my understanding, I should be only including/requiring the file in the functions.php in my child theme right?
My File Structure is like this
**Child Theme**
-functions.php
-deals
--deals.php
In my functions.php i just place the code
require_once('deals/deals.php' );
And in my deals.php, I have this shortcode
add_shortcode('show-deals','show_deals');
function show_deals() {
return 'Show Deals';
}
So it doesn't get rendered. Help
I made a child theme. The CSS I integrated into my child theme and it works perfectly. But now I want to make some amendments in my themes functionality. I copy from my parent theme, for example, product-tab.php to an exact direction in my child theme, modify the file, save, but after refresh no changes in my page. If I do it in the parent theme it works. I think that I should integrate that product-tab.php into my functions.php file (I mean that information first get from my child theme directory not from parent theme by default), but I don't know how because I'm a newbie in PHP coding.
Can anybody give one example how to integrate any PHP file from parent theme to a child theme. Can anybody write an example of a code using the information below?
parent theme direction:
/public_html/wp-content/themes/aloshop/7upframe/element
file name: product-tab.php
child theme direction:
/public_html/wp-content/themes/aloshop-child/7upframe/element
Thank you in advance
If your child theme style sheet is working then you have created the child theme properly. Still reminding you to check the name of parent name included in child theme style.css as 'Template : '
For overwriting the functions you have to copy the php file/functions from parent theme in the same hierarchy or by keeping the same folder file structure.
If your function is still working from parent theme just check from where your function is getting called. It may be from any other file from parent theme which is not included in child theme. In such case, include that file too to he child theme.
Hope this is clear.
If you are using child theme to modify your parent theme {aloshop} then use get_stylesheet_directory() function to get the child theme directory. and then call your other files via functions.php file . To include product-tab.php file via functions.php then put below codes into your child theme's functions.php file,
<?php include_once( get_stylesheet_directory() . '/product-tab.php'); ?>
I am attempting to use this code <?php echo get_template_directory_uri(); ?> to print out the directory reference to my child theme in Wordpress. It goes to the parent theme instead. Reading the codex here https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri it appears as though it should retrieve the directory for the child theme if one has been designated.
Am I doing something wrong?
You'll need to use get_stylesheet_directory();. This will go to the current theme, child or parent.
get_template_directory(); will still go to the parent theme if you are using a child theme.
I have created a child theme to my parent theme and am running into an issue. I am using the child theme functions.php file to call the parent theme .css. The issue with this is that the parent style.css is being called before the bootstrap.css only on my child theme. I have tried using the $dependencies argument but it still isn't working. Was looking for an easy correct solution.
wp_enqueue_style('bootstrap-style', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css');
wp_enqueue_style('alphamedia-style', get_stylesheet_uri(), 'bootstrap-style');
That is the code I am using in my parent functions.php file but it still isn't working.
I'm sure it is something simple I am overlooking. Thank you for the help.
Your on the right track with this but the wp_enqueue_style(); function expects an array to be passed as the $dependencies. Try this:
wp_enqueue_style('alphamedia-style', get_stylesheet_uri(), array('bootstrap-style'));
I'm working on my first child theme and I'm running into a lot of confusion with directories and child themes.
I won't use my real website but I have made a directory in my cPanel dedicated to working on my theme which is at www.wp.example.com
Lets call the template testTemplate. I made a child template called testTemplate-child following the Wordpress codex meaning I registered the parent theme in the child theme's function.php
So wp.example.com loads the style from both the parent theme and the child theme which is desired. What it does not load is the javascript files I enqueued in my child theme's functions.php file.
The confusing part is this, if I navigate to www.wp.example.com/testTemplate-child/ my javascript loads up and works.
I'm wondering if anyone can clear this up for me, why does my child's function.php only work in wp.example.com/testTemplate-child.
It's because your child's theme function.php is added before parent's function.php, that's why you can't override some options, also keep in mind that you'll need to call get_stylesheet_directory() to get child's theme path, because if you do another function, it will load parent's path.
Example to load a javascript file located a /js folder:
$jsPath = get_stylesheet_directory() . '/js/yourScript.js';
wp_enqueue_script( 'child-js', $jsPath, array(), '1.0', true )
More info at: https://codex.wordpress.org/Child_Themes