从头开始开发wordpress主题,我获得了一些基础知识,但是,当我开始制作用于更改页面外观的模板时(比如1、2或3列,有无侧边栏…),我想到了一个主意,那就是在主题中提供选项来轻松更改引导4会很好。容器到。容器液体。
容器div从标题开始。php,以页脚结尾。php。如何在主题中实现此选项?
从头开始开发wordpress主题,我获得了一些基础知识,但是,当我开始制作用于更改页面外观的模板时(比如1、2或3列,有无侧边栏…),我想到了一个主意,那就是在主题中提供选项来轻松更改引导4会很好。容器到。容器液体。
容器div从标题开始。php,以页脚结尾。php。如何在主题中实现此选项?
以下是可行的解决方案(主题名为“zoran”):
//1. Step (Create Customizer section, setting, control)
//In functions.php include or directly put code that goes something like this:
function zoran_customize_register( $wp_customize ) {
$wp_customize->add_section( \'zoran_sekcija\', array(
\'title\' => __( \'Zoran\', \'zoran\' ),
\'priority\' => 35,
) );
$wp_customize->add_setting( \'zoran_postavka\', array(
\'default\' => \'container\',
\'type\' => \'theme_mod\',
\'capability\' => \'edit_theme_options\',
) );
$wp_customize->add_control(\'zoran_control\', array(
\'label\' => \'Container\',
\'section\' => \'zoran_sekcija\',
\'settings\' => \'zoran_postavka\',
\'type\' => \'radio\',
\'choices\' => array(
\'container\' => \'Fluid\',
\'container-fluid\' => \'Fixed\',
),
) );
}
add_action( \'customize_register\', \'zoran_customize_register\' );
//2. Step (Create javascript to manipulate class container)
//In functions.php include or type:
function zoran_customize_js()
{
?>
<script>
div = document.getElementsByClassName("container");
div[0].classList.toggle(<?php echo "\'" . get_theme_mod(\'zoran_postavka\', \'container\') . "\'"; ?>);
</script>
<?php
}
add_action( \'wp_footer\', \'zoran_customize_js\');
我想就是这样。请提出改进建议。我收到了很多警告,比如: Mixed Content: The page at \'https://www.example.in/\' was loaded over HTTPS, but requested an insecure image \'http://www.example.in/wp-content/uploads/2014/12/logo_250.png\'. This content should also be served over HTTPS. 跟踪之后SSL break