Overriding classes and functions in child theme

I’m writing a child theme and need to modify part of the parents theme’s core functions.

To do this I would normally create a new class / function with the same name but the theme that I am using doesnt make use of the

Read More
if (function_exists('function_name'))

or

if (class_exists('class_name'))

What other options do I have to override this parent theme without me needed to modify the parent theme.

Thanks

Related posts

2 comments

  1. i think if you add same name of class or function then it take from child theme function and class then it take from parent.

    For ex.

    Child Theme

    if ( ! function_exists( 'function_name' ) ) {
      function function_name(){
        echo 'This is child theme';
      }
    }
    

    Parent Theme

    if ( ! function_exists( 'function_name' ) ) {
      function function_name(){
        echo 'This is parent theme';
      }
    }
    

    Same for class

Comments are closed.