Strange error message when using child themes

I used the tutorial from here to create a child theme. I've modified functions.php, style.css and the content.php files.

However, I now have some strange error messages in my log that are not there when using the parent theme:

PHP Warning:  call_user_func_array() expects parameter 1 to be a valid callback, function 'child_parent_styling' not found or invalid function name in /home/******/public_html/wp/wp-includes/class-wp-hook.php on line 298
PHP Warning:  call_user_func_array() expects parameter 1 to be a valid callback, function 'child_site_info' not found or invalid function name in /home/******/public_html/wp/wp-includes/class-wp-hook.php on line 298
  • Adam Czajczyk

    Hello angeljs,

    I hope you're well today and thank you for your question!

    The message means that functions "child_parent_styling" and "child_site_info" doesn't exist. It may be because there's indeed no such functions or that their names are misspelled.

    It's a bit difficult to diagnose without checking an actual code so could you please share the content of your child theme's "functions.php" file here? I hope that the look at the code will let us solve that :slight_smile:

    Best regards,
    Adam

  • angeljs

    Thank you for your reply. I have another error message:

    PHP Fatal error:  Call to undefined function get_header() in /home/******/public_html/wp/wp-content/themes/fluida-child/single.php on line 1
    PHP Fatal error:  Call to undefined function add_action() in /home/******/public_html/wp/wp-content/themes/fluida-child/functions.php on line 2

    Here's my functions.php:

    <?php
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
    
    function enqueue_parent_styles() {
       wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }
    
    add_filter('frmpro_fields_replace_shortcodes', 'frm_make_shortcode', 10, 4);
    function frm_make_shortcode($replace_with, $tag, $atts, $field){
      if(isset($atts['link_full'])){
         $new_val = '';
         foreach((array)$replace_with as $v){
           if(is_numeric($v)){
             $full = wp_get_attachment_image_src($v, 'full');
             $thumb = wp_get_attachment_image_src($v);
             $new_val .= '<a href="'. $full[0] .'"><img src="'. $thumb[0] .'" /></a>&nbsp;';
           }
         }
         return $new_val;
      }
      return $replace_with;
    }
    
    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        $args['teeny'] = false;
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );
    function bbp_tinymce_paste_plain_text( $plugins = array() ) {
        $plugins[] = 'paste';
        return $plugins;
    }
    add_filter( 'bbp_get_tiny_mce_plugins', 'bbp_tinymce_paste_plain_text' );
    
    //Exclude Category
    function excludeCat($query) {
    if ( $query->is_home ) {
    $query->set('cat', '-1333,-1362,-1356,-1357,-1358,-1359,-1361,-1362,-1363,-1364,-1365,-1366,-1367,-1368,-1369,-1370,-1371,-1372,-2115,-2116,-2117');
    }
    return $query;
    }
    add_filter('pre_get_posts', 'excludeCat');
    //End Exclude Category
    
    ////////////////////////////////////////////////////////////////////////
    // BuddyPress Profile URL Integration //////////////////////////////////
    ////////////////////////////////////////////////////////////////////////
    add_filter('wpdiscuz_profile_url', 'wpdiscuz_bp_profile_url', 10, 2);
    function wpdiscuz_bp_profile_url($profile_url, $user) {
        if ($user && class_exists('BuddyPress')) {
            $profile_url = bp_core_get_user_domain($user->ID);
        }
        return $profile_url;
    }
    
    add_filter( 'the_title', 'wpb_sponsored' );
    function wpb_sponsored( $title ) {
       global $post;
       $sponsored_text = '<img src="http://simfansuk.com/wp/images/featured.png" border="0" alt="Featured_post"/> ';
       $sponsored = get_post_meta($post->ID, 'sponsored', true);
       if( $sponsored == 'true' && in_the_loop() ){
           return $sponsored_text.$title;
       }
       return $title;
    }
    
    add_filter('frm_upload_folder', 'frm_custom_upload');
    function frm_custom_upload( $folder ) {
        global $current_user;
        $folder = $folder . '/' . $current_user->user_login;
        return $folder;
    }
    
    add_filter('frm_validate_field_entry', 'my_custom_validation', 8, 3);
    function my_custom_validation($errors, $posted_field, $posted_value){
      if($posted_field->id == 229 and $posted_value == 'No'){ //change 25 to the ID of the field
        $_POST['frm_wp_post']['=comment_status'] = 'closed';
      }
      return $errors;
    }
    
    // adding a subnav menu tab on a profile page for author's posts
    // add this snippet into theme's functions.php
    
    function authorposts_onprofile() {
    global $bp;
    	?>
    	<li id="activity-reshares"><a href="<?php echo home_url(). '/author/' . bp_get_displayed_user_username(). '/'; ?>" title="<?php bp_displayed_user_fullname(); ?>'s Posts">User Posts</a></li>
    	<?php
    }
    
    add_action('bp_member_options_nav', 'authorposts_onprofile');
    
    function my_mce_buttons( $buttons ) {
    	$index = array_search( 'WPTS', $buttons );
    	if ( $index !== false ) { unset( $buttons[$index] ); }
    
    	return $buttons;
    }
    add_filter( 'mce_buttons', 'my_mce_buttons' );
    
    add_action('save_post', 'remove_tags_function', 10, 1); //whenever a post is saved, run the below function
    
    function remove_tags_function( $post_id ){
        if(!current_user_can('manage_options')){ // if the logged in user cannot manage options (only admin can)
            $post_tags = wp_get_post_terms( $post_id, 'post_tag', array( 'fields'=>'names' ) ); //grab all assigned post tags
            $pos = array_search( 'featured', $post_tags ); //check for the prohibited tag
            if( false !== $pos ) { //if found
                unset( $post_tags[$pos] ); //unset the tag
                wp_set_post_terms ($post_id, $post_tags, 'post_tag'); //override the posts tags with all prior tags, excluding the tag we just unset
            }
        }//end if. If the current user CAN manage options, the above lines will be skipped, and the tag will remain
    }
    
    /********************************************
    *  custom "powered by" text to be displayed instead of
    *  the copyright link; supports HTML; write your
    *  text/HTML between the quotes; escape single
    *  quotes in the text with backslash, eg:
    *  $custom_footer_text = 'this is my site\'s "<i>custom powered by text</i>"';
    */
    $custom_powered_by = '';
    
    /********************************************
    *  show/hide "Powered by Wordpress" link
    *  consult Wordpress terms of use before changing this
    *  values:
    *     false = display link to wordpress
    *     true  = hide link                    */
    $hide_wordpress_link = true;
    
    add_action('wp_head','child_parent_styling', 4);
    
    // remove tempera functions action hooks
    function remove_tempera_functions() {
        remove_action('cryout_footer_hook', 'tempera_site_info',99);
    }
    add_action('init','remove_tempera_functions');
    
    // attach child theme functions hooks
    add_action('cryout_footer_hook','child_site_info',99);
    
    add_filter('frm_filter_auto_content', '__return_false');
    
    ?>
  • Adam Czajczyk

    Hello angeljs,

    Thank you for sharing the code.

    The "child_parent_styling()" and "child_site_info" function are indeed not defined.

    This part of code:

    $hide_wordpress_link = true;
    
    add_action('wp_head','child_parent_styling', 4);

    should be like this:

    function child_parent_styling() {
    $hide_wordpress_link = true;
    return $hid_wordpress_link;
    }
    add_action('wp_head','child_parent_styling', 4);

    This part

    add_action('cryout_footer_hook','child_site_info',99);

    should also be calling out an existing function "child_site_info" but I'm not sure what to suggest because I do know now what that function should do.

    Please also note that "functions.php" file of a child theme is actually loaded before the parent theme's "functions.php" is. Therefore, it can't related on parent theme's functions.php functions directly.

    That said, please try that solution (replacing the first code and adding a "child_site_info()" function) and let me know if that solved at least the initial issue. If you have further questions on that let me know please.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.