child theme functions.php not sure i'm doing it right
-
i have zero coding experience or knowledge and the more i research, the more i read, the more confused and doubtful i am that i’ve set it up right. i’ve got two questions, if anyone would help me:
1. my parent theme’s name is Sequential, the child is Sequential Child, and the text domain is sequential-child. as per the codex i’ve put a blank functions.php file in the root of the child and added the following code right after the <?php tag:
[ Moderator note: Code fixed, please wrap code in backticks or use the code button. ]
add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' ); function enqueue_parent_theme_style() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); }
i’m supposed to “fill it in” aren’t i? this is the template of the code, but i have to change it, don’t i? can someone please tell me exactly how this enqueue is supposed to be? all the advice forums i’ve read and the youtube videos i’ve seen don’t ever really give Practical Examples for idiots like me. @import looks easier, of course, but i really want to learn, and to do this right with enqueue.
2. i have woocommerce installed and running. i seem to have successfully wrapped the theme by creating a woocommerce.php file and leaving it the parent theme’s directory (is this right?) and i added the following code to the child theme’s functions.php file as per the woothemes documentation:
add_filter( 'woocommerce_enqueue_styles', 'dequeue_woocommerce_general_stylesheet' ); function dequeue_woocommerce_general_stylesheet( $enqueue_styles ) { unset( $enqueue_styles['woocommerce-general'] ); return $enqueue_styles; }
this seems to work; i search on the internet for what i want to change and the code for it, i add it to the functions.php file, and 1 time out of 6 it works. the process is long and torturous, so i’m doubting that i’ve got everything set up right.
and about localisation. i don’t want to translate wordpress admin itself into a different language, but i do want to translate woocommerce, and the website. this is confusing too. i understand that i put the woocommerce mo and po files in sequential-child/woocommerce/languages, but what exactly is the functions code and how exactly do i point it at the languages folder? is it this?:
/*load translation file for woocommerce*/ function my_child_theme_setup() { load_child_theme_textdomain( 'sequential-child', get_stylesheet_directory() . '/languages' ); } add_action( 'after_setup_theme', 'my_child_theme_setup' );
i have to modify the names in this code too, don’t i, but how exactly? do i replace “my_child_theme_setup” with “sequential_child_setup?” i’m also confused because other forums just mention this line of code for gettext:
/*load tranlation file for woocommerce*/ load_child_theme_textdomain( 'sequential-child' );
this is all great fun but terrible slow and hard work. i just want to be sure that i have these basic setups right. i’ve still got to really figure out how to use the google Inspect Element to simply copy and past what i want to change into my child theme style.css file.
i’m adding code to these two files – functions.php and style.css – but do i have to copy the original parent theme file over to the child folder or not?
my apologies for the long post and the general pathetic uselessness, but if someone can explain this to me and write it down for me like i’m five year’s old i’d be extremely grateful.
cheers.
- The topic ‘child theme functions.php not sure i'm doing it right’ is closed to new replies.