• Resolved Didier77

    (@didier77)


    It is not possible to override some functions coded in functions.php in a child theme as function_exists (see below) is not systematically set for all functions:

    if ( ! function_exists( ‘xxx’ ) ) :

Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Which functions in particular would you like to override with your child theme?

    Thread Starter Didier77

    (@didier77)

    I try to override ct_author_add_meta_elements function (I don’t want to display the theme version).

    Theme Author Ben Sibley

    (@bensibley)

    Okay I see. Here’s what you can do:

    Update the function shared in the other thread to this:

    function ct_author_child_remove_wp_version() {
      remove_action( 'wp_head', 'wp_generator', 1 );
      remove_action( 'wp_head', 'ct_author_add_meta_elements', 1 );
    }
    add_action('after_setup_theme', 'ct_author_child_remove_wp_version');

    That will remove the theme template tag, but it will also remove two other meta elements your site needs. So add this function afterwards to re-add those other meta elements:

    function ct_author_child_add_meta_elements() {
    
    	$meta_elements = '';
    
    	/* Charset */
    	$meta_elements .= sprintf( '<meta charset="%s" />' . "\n", get_bloginfo( 'charset' ) );
    
    	/* Viewport */
    	$meta_elements .= '<meta name="viewport" content="width=device-width, initial-scale=1" />' . "\n";
    
    	echo $meta_elements;
    }
    add_action( 'wp_head', 'ct_author_child_add_meta_elements', 1 );
    Thread Starter Didier77

    (@didier77)

    Thanks! This solves my issue!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Not compatible with child themes’ is closed to new replies.