我正在学习如何从头开始制作WordPress主题&我现在面临一个不好的问题。问题是我添加的CSS样式不适用于我的主题的菜单导航。我的WordPress自定义主题没有获取CSS样式
这里的index.php
文件:
<?php
get_header();
if (have_posts()):
while (have_posts()) : the_post(); ?>
<article class="post">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<h2><?php the_content(); ?></h2>
</article>
<?php endwhile;
else:
echo '<p>No content found!</p>';
endif;
get_footer();
?>
这里的header.php
文件:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width">
<title><?php bloginfo('name'); ?></title>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div class="container">
<header class="site-header">
<h1><a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a></h1>
<h5><?php bloginfo('description'); ?></h5>
<nav class="site-nav">
<?php
$args = array(
'theme_location' => 'primary'
);
?>
<?php wp_nav_menu($args); ?>
</nav>
</header>
正如你可以看到我加入的CSS类站点导航到标签,然后我将其编码为css样式:
.site-nav ul{
margin:0;
padding:0;
}
.site-nav ul:before, .site-nav ul:after{content: "";display:table;}
.site-nav ul:after{clear:both;}
.site-nav ul{*zoom:1;}
.site-nav ul li{
list-style:none;
float:left;
}
但每当我跑的主题,我得到这个画面:
但请注意,我已经有functions.php
它增加了CSS样式和我已经加入其他CSS样式,如身体或等来它和它的作品,但我不明白为什么菜单导航不会改变!
这里的functions.php
:
<?php
function learningWordpress_resources(){
wp_enqueue_style('style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts','learningWordpress_resources');
register_nav_menus(array(
'primary' => __('Primary Menu'),
'footer' => __('Footer Menu'),
));
?>
下面是完整的CSS code
包括头部CSS路径,并添加样式表文件,所有的CSS。它会自动工作 – Gulshan
是的style.css文件放置在您主题文件夹? – Gulshan
请提供一个functions.php –