使用wordpress主题自定义api时,背景颜色不会改变

时间:2017-06-26 08:44:08

标签: php css wordpress

这是我在functions.php中的代码: -

<?php

add_theme_support('menus');

register_nav_menus(

array('primary' =>__('Primary Menu'))

);


function awesome_script_enque(){



 wp_enqueue_style('customstyle',get_template_directory_uri().'css/awesome.css',array(),'1.0.0','all');




wp_enqueue_script('customjs',get_template_directory_uri().'css/awesome.js',array(),'1.0.0',true);

}

add_action('wp_enqueue_scripts','awesome_script_enque');

function awesome_customizer_register($wp_customize){

$wp_customize->add_section('awesome_colors',array(
'title' => __('Colors','awesome'),
'description'=>'Modify the theme colour' )
);
$wp_customize->add_setting('background_color',array(
'default' => '#fff',
));

$wp_customize->add_control( new 
WP_Customize_Color_Control($wp_customize,'background_color',array(
'label' =>__('Edit Background Color','awesome') ,
'selection' =>'awesome_colors',
'settings'=>'background_color'
 )));

 }
 add_action('customize_register','awesome_customizer_register');

 function customtheme_customize_css()
 {
 ?>
 <style type="text/css">
 h1{color:<<?php echo get_theme_mod('background_color','#fff'); ?>}
</style>
<?php
}
?>

我提到了很多教程,所有这些教程都有相同的过程。仍然我无法在自定义区域中获得名为Colors的定制器框,其中有菜单,静态首页等选项.....可以任何人指出我做错了吗?

1 个答案:

答案 0 :(得分:2)

以下是代码中的小错误。在最后一行,您更改了字体颜色,而不是背景,也没有通过挂钩添加功能。以下是正确的代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

if let notification = launchOptions?[.remoteNotification] as? [String: AnyObject] {
        let aps = notification["aps"] as! [String : AnyObject]

        let storybaord = getStoryboardObject(storyboardName: "Main")as UIStoryboard
        let aboutUsObj = storybaord.instantiateViewController(withIdentifier: "NotificationViewController")as! NotificationViewController
        aboutUsObj.aps = aps
        let navigationController: UINavigationController? = (AppDelegate.getDelegate().window?.rootViewController as? UINavigationController)
        navigationController?.pushViewController(aboutUsObj, animated: true)
    }

    return true
}