guru's:D
我在header.php文件中使用IF-staments时遇到问题。
我正在使用wordpress平台。下面的代码应通过检查用户当前所在的页面来显示不同样式的标题。
我的问题:当我在任何页面中调用get_header();
时,我会从中获取所有代码
header.php文件,似乎功能并不关心我的IF-stament
header.php文件。
非常感谢任何帮助。
下面的代码是我的header.php文件。
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
<?php
$post_obj = $wp_query->get_queried_object();
var_dump($slug);
?>
<?
if (is_page($slug == "student_info")) {
?>
<div id="header">
<div class="header-content">
<div class="link-1">
<a href=""><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_activated_1.png'/> </a>
</div>
<div class="link-2">
<a href="student_valg"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_2.png'/> </a>
</div>
<div class="link-3">
<a href="student_laeringsmaal"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_3.png'/> </a>
</div>
<div class="link-4">
<a href="student_status"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_4.png'/> </a>
</div>
<div class="link-5">
<a href="student_dagbog"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_5.png'/> </a>
</div>
<div class="link-6">
<a href="student_evaluering"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_6.png'/> </a>
</div>
</div>
</div>
<?
} elseif ($slug == "student_valg") {
?>
<div id="header">
<div class="header-content">
<div class="link-1">
<a href="student_info"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_1.png'/> </a>
</div>
<div class="link-2">
<a href=""><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_activated_2.png'/> </a>
</div>
<div class="link-3">
<a href="student_laeringsmaal"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_3.png'/> </a>
</div>
<div class="link-4">
<a href="student_status"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_4.png'/> </a>
</div>
<div class="link-5">
<a href="student_dagbog"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_5.png'/> </a>
</div>
<div class="link-6">
<a href="student_evaluering"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_6.png'/> </a>
</div>
</div>
</div>
<?
} elseif ($slug == "student_laeringmaal") {
?>
<div id="header">
<div class="header-content">
<div class="link-1">
<a href="student_info"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_1.png'/> </a>
</div>
<div class="link-2">
<a href="student_valg"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_2.png'/> </a>
</div>
<div class="link-3">
<a href=""><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_activated_3.png'/> </a>
</div>
<div class="link-4">
<a href="student_status"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_4.png'/> </a>
</div>
<div class="link-5">
<a href="student_dagbog"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_5.png'/> </a>
</div>
<div class="link-6">
<a href="student_evaluering"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_6.png'/> </a>
</div>
</div>
</div>
<?
} elseif ($slug == "student_status") {
?>
<div id="header">
<div class="header-content">
<div class="link-1">
<a href="student_info"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_1.png'/> </a>
</div>
<div class="link-2">
<a href="student_valg"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_2.png'/> </a>
</div>
<div class="link-3">
<a href="student_laeringsmaal"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_3.png'/> </a>
</div>
<div class="link-4">
<a href=""><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_activated_4.png'/> </a>
</div>
<div class="link-5">
<a href="student_dagbog"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_5.png'/> </a>
</div>
<div class="link-6">
<a href="student_evaluering"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_6.png'/> </a>
</div>
</div>
</div>
<?
} elseif ($slug == "student_dagbog") {
?>
<div id="header">
<div class="header-content">
<div class="link-1">
<a href="student_info"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_1.png'/> </a>
</div>
<div class="link-2">
<a href="student_valg"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_2.png'/> </a>
</div>
<div class="link-3">
<a href="student_laeringsmaal"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_3.png'/> </a>
</div>
<div class="link-4">
<a href="student_status"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_4.png'/> </a>
</div>
<div class="link-5">
<a href=""><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_activated_5.png'/> </a>
</div>
<div class="link-6">
<a href="student_evaluering"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_6.png'/> </a>
</div>
</div>
</div>
<?
} else {
?>
<div id="header">
<div class="header-content">
<div class="link-1">
<a href="student_info"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_1.png'/> </a>
</div>
<div class="link-2">
<a href="student_valg"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_2.png'/> </a>
</div>
<div class="link-3">
<a href="student_laeringsmaal"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_3.png'/> </a>
</div>
<div class="link-4">
<a href="student_status"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_4.png'/> </a>
</div>
<div class="link-5">
<a href="student_dagbog"><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_5.png'/> </a>
</div>
<div class="link-6">
<a href=""><img src='../wp-content/themes/tutorial_theme-child/images/proces_punkt_activated_6.png'/> </a>
</div>
</div>
</div>
<?
}
?>