Override Constants in Child theme

Constants can not be redefined that easily. https://stackoverflow.com/questions/8465155/redefine-constants-in-php So, the constants from child themes will be used instead of parents one. Though, there will be a warning, but that shouldn’t create any problem if you disable warning. You should add constants like this if you don’t want any warning: if ( !defined(‘CONSTANT’) ) define(‘CONSTANT’, ‘constant_value’); … Read more

How to store / access files in child theme folder

Can you place custom .php files directly inside the child theme folder? Yes, of course you can. WordPress is PHP. What works in PHP works in WordPress. Some of the research we found says you must write your custom PHP functions inside of the functions.php file. Nonsense. Many themes segregate code into multiple files, including … Read more

Indirect modification of overloaded property WP_Post::$classes has no effect

If “line 45” is the one that starts with $element->classes[] in your display_element method then try something like this: public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { $element->has_children = ! empty( $children_elements[ $element->ID ] ); if ( ! isset( $element->classes ) ) { $element->classes = array(); } $element->classes[] = ( … Read more

Adding PHP/HTML code inside page from custom template

This is how to code the shortcode function foobar_func( $atts ){ return “foo and bar”; } add_shortcode( ‘foobar’, ‘foobar_func’ ); And to execute a function using output buffering add_shortcode( ‘shortcode_tag’, ‘function_name’ ); function function_name($atts) { ob_start(); // Add your code $var = ob_get_contents(); ob_end_clean(); return $var; }

Child themes & updates?

First thing first, that’s a very good question! Now let me tell you what I’ve done to definitely kill the annoying proceedings you have described. Keep WordPress under Git Control. There are a multitude of articles on the web that can guide you from the basics to advanced steps. I used to repeat the proceedings … Read more

Child theme functions.php not executing

Our problem was that our style.css file was in a css folder inside the child theme directory, not at the root of the child theme. When we placed a style.css file at the root and included the comment block with theme name and template it picked up the functions.php file as expected.