0

大师的 :D

我在 header.php 文件中使用 IF 语句时遇到问题。

我正在使用wordpress平台。下面的代码应该通过检查用户当前所在的页面来显示不同样式的标题。

我的问题:当我调用get_header();任何页面时,我从 header.php 文件中获取所有代码,似乎这些函数并不关心我在 header.php 中的 IF 语句。

任何帮助是极大的赞赏。

下面的代码是我的 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>
<?
}
?>
4

0 回答 0