get_template_part() (1 post)

  1. Bob Wagstaff
    Posted 2 years ago #

    I've written a theme and used theme customization, but rather than clutter up my functions.php with all the code I have added the following code

    get_template_part( 'headertextcolor');
    	get_template_part( 'defaultbackground');
    	get_template_part( 'menuwalker');

    and then added additional php files to include the customization. For example my defaultbackground.php file is

    //Custom background
    		$custbackgr = array(
    			'default-color'			 => '#454543',
    			'default-image'          => get_template_directory_uri() . '/img/defaultbackgroundimage.jpg',
    			'wp-head-callback'       => '_custom_background_cb',
    			'admin-head-callback'    => '',
    			'admin-preview-callback' => ''
    		add_theme_support( 'custom-background', $custbackgr );

    This has worked fine in my test site, but when I've moved the theme into my live site all my get_template_part() commands have failed and simply been ignored, meaning there is no customization and the background colour is white rather than charcoal grey.

    I've overcome the issue by simply replacing the get_template_part() commands with the code from the files which they were supposed to go and get.

    But is this normal behaviour? And how can I make the get_template_part() command work in my live site?

Topic Closed

This topic has been closed to new replies.

About this Topic