Editing the functions.php file in a child theme to modify Google Fonts

Hi there,

I am currently working with Shapely, thinking of converting my existing WordPress installation to it.

I’ve created a child theme so as to modify CSS and other things w/o touching the original files, per best practice.

Where I am a bit stuck is in editing the functions.php file so as to modify the Google Fonts and perhaps other things like squelching FontAwesome and other JS I may not need.

Normally, I would try to put something like the into the functions.php file, for example; however, I’m doing something wrong, because this breaks the site.

Can anyone give me a hint as to what the exact block of code would be?

Thanks,

Kim

PS: The site is not in production yet, so it’s not visible. Nothing to see yet.

/**
 * Enqueue scripts and styles.
 */
function shapely_scripts() {
    // Add Bootstrap default CSS
    wp_enqueue_style( 'shapely-bootstrap', get_template_directory_uri() . '/inc/css/bootstrap.min.css' );

    // Add Font Awesome stylesheet
    // wp_enqueue_style( 'shapely-icons', get_template_directory_uri().'/inc/css/font-awesome.min.css' );

    // Add Google Fonts
    wp_enqueue_style( 'shapely-fonts', '//fonts.googleapis.com/css?family=Raleway:100,300,400,500,600,700,900%7COpen+Sans:400,500,600');

    // Add slider CSS
	wp_enqueue_style( 'flexslider-css', get_template_directory_uri().'/inc/css/flexslider.css' );

    //Add custom theme css
    wp_enqueue_style( 'shapely-style', get_stylesheet_uri() );

	
	wp_enqueue_script( 'shapely-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );

	wp_enqueue_script( 'shapely-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20160115', true );

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}

    
    if( post_type_exists( 'jetpack-portfolio' ) ){
    	 wp_enqueue_script( 'jquery-masonry' );
	}

    if (post_type_exists( 'jetpack-portfolio' ) ) {
		wp_enqueue_script( 'jquery-masonry', array( 'jquery' ), '20160115', true );
    }
    
    // Add slider JS
	wp_enqueue_script( 'flexslider-js', get_template_directory_uri() . '/js/flexslider.min.js', array('jquery'), '20160222', true );
    
    if ( is_page_template( 'template-home.php' ) ) {
        wp_enqueue_script( 'shapely-parallax', get_template_directory_uri() . '/js/parallax.min.js', array('jquery'), '20160115', true );
    }

    wp_enqueue_script( 'shapely-scripts', get_template_directory_uri() . '/js/shapely-scripts.js', array('jquery'), '20160115', true );
}
add_action( 'wp_enqueue_scripts', 'shapely_scripts' );

// add admin scripts
function shapely_admin_script($hook) {

    wp_enqueue_media();
    
    if( $hook == 'widgets.php' || $hook == 'customize.php' ){
      wp_enqueue_script( 'shapely_cloneya_js', get_template_directory_uri() . '/js/jquery-cloneya.min.js', array( 'jquery' ) );
      wp_enqueue_script('widget-js', get_template_directory_uri() . '/js/widget.js', array('media-upload'), '1.0', true);
      
      // Add Font Awesome stylesheet    
      wp_enqueue_style( 'shapely-icons', get_template_directory_uri().'/inc/css/font-awesome.min.css' );
    
    }
}
add_action('admin_enqueue_scripts', 'shapely_admin_script');

Hi Kim,

I hope you are well today and thank you for your question.

Actually what you are doing wrong is that the child theme doesn’t overwrite functions.php file like other template files so if you just copy functions from functions.php file of theme in to functions.php file of child theme then it gets declared twice generating error.

You will find more information about child theme on the following page.

https://codex.wordpress.org/Child_Themes

Basically you must not declare function again in the child theme functions.php file and should use the following functions too remove or add js, CSS and font files from the theme.

Best Regards,
Movin