所以我正在通过一个Wordpress主题课程,我们正在创建我们的页面模板设置。页面加载正常。
<?php get_header(); ?>
<section id="page-template">
<div class="container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div>
</section>
<?php get_footer(); ?>我所有的css文件都链接到页眉中,但是由于某种原因,当我加载我创建的页面时,它们没有加载我们为该页面创建的CSS。我们正在将所有的css文件导入到一个main.css文件中,这就是我遇到的问题。
@import "pagetemplate/page.css";在该文件中,我们有一些基本的css来测试它,并确保它连接。
#page-template {padding: 80px 0;}
#page-template .container {padding: 0 15px;}很抱歉,如果它到处都是,我将很高兴在任何问题上展开。
我要补充的是,我的header.php页面有css链接
<link rel="stylesheet" href="<?php echo get_bloginfo('template_directory'); ?>/css/main.css">发布于 2019-09-01 06:38:27
将php代码更改为
<?php bloginfo("template_directory"); ?>所以你的链接看起来像这样
<link rel="stylesheet" href="<?php bloginfo("template_directory"); ?>/css/main.css">发布于 2019-09-02 14:12:35
好的,所以我就想通了。我不确定这是不是很好的练习方式,但我做到了!我只是将css文件夹和文件直接链接到page.php中。
<link rel="stylesheet" href="<?php echo get_bloginfo('template_directory'); ?>/css/page-template/mypage.css">我将这个常规的css链接添加到我的page.php模板中,因为我的get_header()不能从我的主页识别我的css链接。这是最终的视图。
<link rel="stylesheet" href="<?php echo get_bloginfo('template_directory'); ?>/css/page-template/mypage.css">
<?php get_header(); ?>
<section id="page-temp">
<div class="container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div>
</section>
<?php get_footer(); ?>https://stackoverflow.com/questions/57741941
复制相似问题