目前,我正在通过转换html来开发wordpress中的第一个主题。在我的首页(wordpress中的front-page.php)中有一张幻灯片。使用html可以很好地工作。但是,当我将其放置在front-page.php中,并将其放置在当前正在开发的主题文件夹中的style.css上的样式中时,它就是这样。
这是我的代码
front-page.php(仅滑块部分)
<!-- Slider -->
<section class="slider pull-left width-wide clear-both">
<div class="wrap">
<div class="cont">
<div class="slide" style="background-image:url(http://localhost:8080/Towing/wp-content/uploads/2019/12/slide1.jpg);"></div>
<div class="slide" style="background-image:url(http://localhost:8080/Towing/wp-content/uploads/2019/12/slide2.jpg);"></div>
<div class="slide" style="background-image:url(http://localhost:8080/Towing/wp-content/uploads/2019/12/slide3.jpg);"></div>
<div class="slide" style="background-image:url(http://localhost:8080/Towing/wp-content/uploads/2019/12/001.png);"></div>
</div>
<div id="nav" style="font-size:16px;" class="pull-right">
</div>
</section><!-- // Slider -->
style.css
.slider {
position:relative;
z-index:90
}
.slider .wrap {
max-width:1175px !important
}
.slider .slide {
border-top:8px solid #fff;
width:100%;
height:400px !important;
background-size:cover !important
}
function.php
<?php
function load_stylesheets(){
wp_register_style('reset', get_template_directory_uri() . '/assets/css/reset.min.css' , array(), 1, 'all');
wp_enqueue_style('reset');
wp_register_style('bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css' , array(), 1, 'all');
wp_enqueue_style('bootstrap');
wp_register_style('lightbox', get_template_directory_uri() . '/assets/css/lightbox.css' , array(), 1, 'all');
wp_enqueue_style('lightbox');
wp_register_style('pre-classes', get_template_directory_uri() . '/assets/css/pre-classes.css' , array(), 1, 'all');
wp_enqueue_style('pre-classes');
wp_register_style('style', get_template_directory_uri() . '/assets/css/style.css' , array(), 1, 'all');
wp_enqueue_style('style');
wp_register_style('custom', get_template_directory_uri() . '/custom.css' , array(), 1, 'all');
wp_enqueue_style('custom');
}
add_action('wp_enqueue_scripts', 'load_stylesheets');
//Load Scripts
function addjs(){
wp_register_script('jquery' , get_template_directory_uri() . '/assets/js/jquery.min.js' , array() , 1, 1, 1);
wp_enqueue_script('jquery');
wp_register_script('bootstrap' , get_template_directory_uri() . '/assets/js/bootstrap.min.js' , array() , 1, 1, 1);
wp_enqueue_script('bootstrap');
wp_register_script('cycle' , get_template_directory_uri() . '/assets/js/cycle.min.js' , array() , 1, 1, 1);
wp_enqueue_script('cycle');
wp_register_script('imagelightbox' , get_template_directory_uri() . '/assets/js/imagelightbox.min.js' , array() , 1, 1, 1);
wp_enqueue_script('imagelightbox');
wp_register_script('plugins' , get_template_directory_uri() . '/assets/js/plugins.jquery.js' , array() , 1, 1, 1);
wp_enqueue_script('plugins');
wp_register_script('custom-jquery' , get_template_directory_uri() . '/assets/js/custom.jquery.js' , array() , 1, 1, 1);
wp_enqueue_script('custom-jquery');
wp_register_script('gmap3' , get_template_directory_uri() . '/assets/js/gmap3.min.js' , array() , 1, 1, 1);
wp_enqueue_script('gmap3');
wp_register_script('custom' , get_template_directory_uri() . '/custom.js' , array() , 1, 1, 1);
wp_enqueue_script('custom');
}
add_action('wp_enqueue_scripts', 'addjs');
?>
非常感谢您的关注和反馈。
谢谢!
答案 0 :(得分:0)
您应该检查主题目录中的层次结构。
大多数时候,像functions.php这样的文件不在正确的位置,
或wp_register_style()函数的第二个参数不正确!