教祖:D
header.php ファイルで IF ステートメントを使用すると問題が発生します。
私はワードプレスプラットフォームを使用しています。以下のコードは、ユーザーが現在どのページにいるかを確認することで、さまざまなスタイルのヘッダーを表示する必要があります。
私の問題: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>
<?
}
?>