Hot answers tagged

4

Child themes are not the only way to extend a theme, not even the best. Many themes offer hooks: actions and filters. You can use these to change the output per plugin. Let’s say you have a theme named Acme, and its index.php contains the following code: get_header(); do_action( 'acme.loop.before', 'index' ); ?> <div id="container"> &...


3

The new function in your child theme's functions.php cannot override a function from the parent's functions.php file unless that function is written to be pluggable, i.e. declared with if (!function_exists('alterna_get_social_list')) Per the documentation on Child Themes and how they inherit from child functions.php files: Using functions.php Unlike ...


2

You are missing part of the boilerplate needed in the comments area at the top of the stylesheet file. You need a line that says: Template: [name of parent theme folder] For example if the folder in the /wp-content/themes folder for the parent theme is integrative-wisdom you would have: /*! Theme Name: Integrative Wisdom Child Theme URI: http://...


2

Is there are better way to change this (annoying) variable please? The Twenty Sixteen theme provides you with the twentysixteen_content_width filter, where the default is 840. To modify it you should be able to use this within your child theme's functions.php file: add_filter( 'twentysixteen_content_width', function( $content_width ) { // Override ...


1

What I see here is you are not using dependency parameter in your child theme to load the css. wp_enqueue_style() accepts 5 arguments. The 3rd one is dependency. This dependency allows your css file to load after that. So if you will add the parent stylesheet handle in child dependency then this will load after your parent css file. For more information ...


1

For me the rule of thumb is am I extending/revising an existing theme? If so I'll want to be able to update the theme (assuming it's well supported) without nuking all my changes. You can read more here in the codex. If I'm creating something custom I find it best to just use my own starter theme (or something like Underscores) and edit the theme itself.


1

If you want to use a variable from a another context in a function, create a class: class CustomLog { private $debug_msg = ""; public function __construct( $msg ) { $this->debug_msg = $msg; } public function log() { error_log( $this->debug_msg, 0 ); } } add_action( 'init', [ new CustomLog( "Hi there!" ), '...



Only top voted, non community-wiki answers of a minimum length are eligible