簡體   English   中英

如何重定向文件以在 header.php 中執行

[英]How to redirect file to execute in header.php

我正在嘗試解決有關如何為字體真棒菜單欄設置動畫以切換單擊的問題。

我沒能做到,但為了解決這個問題,我在我的主題文件夾中創建了一個文件並將其命名為Menu Bars 在這個文件中,我放置了以下代碼:

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" 
content="width=device- 
width, initial-scale=1">

<style>


.container {

display: inline-block;

cursor: pointer;

}

.bar1, .bar2, .bar3 {

width: 35px;

height: 5px;

background-color: #333;

margin: 6px 0;

transition: 0.4s;

}

.change .bar1 {

-webkit-transform: 
rotate(-45deg) 
translate(-9px, 6px);

transform: rotate(-45deg) 
translate(-9px, 6px);

}.change .bar2 {opacity: 
0;} .change .bar3 {

-webkit-transform: 
rotate(45deg) 
translate(-8px, -8px);

transform: rotate(45deg) 
translate(-8px, -8px);

}

</style>

</head>

<body>



<div class="container" 
onclick="myFunction(this)">

<div class="bar1"></div>

<div class="bar2"></div>

<div class="bar3"></div>

</div>

<script>

function myFunction(x) {

x.classList.toggle
("change");

}

</script>

</body>

</html>

然后我查看了我的 header.php 並將<i class="fa fa-bars"></i>替換為

<?php header("Location: 
home/qpgteouc/public_
html/wp- 
content/themes/shapel
y/Menu"); ?>

我假設這會重定向到這個文件`菜單欄的位置:

home/qpgteouc/public_
html/wp- 
content/themes/shapel
y/Menu

並執行文件,創建我想要的菜單欄 animation。

實際發生的情況是該站點以too many redirects為由拒絕加載。

我正在嘗試做的事情是否可行,如果可以,我需要做什么?

這是我在提出有用的建議后到目前為止所擁有的,但仍然無法正常工作。

<header id="masthead" class="site- 
header<?php echo get_theme_mod( 
'mobile_menu_on_desktop', true ) ? ' mobile-menu' : ''; ?>" role="banner">
    <div class="nav-container">
        <nav <?php echo $style; ?> id="site-navigation" class="main-navigation" role="navigation">
            <div class="container nav-bar">
                <div class="flex-row">
                    <div class="module left site-title-container">
                        <?php shapely_get_header_logo(); ?>
                    </div>
                    <div class="module widget-handle mobile-toggle right visible-sm visible-xs">

                        <?php require("home/qpgteouc/public_html/wp-content/themes/shapely/Menu_bars_"); ?>





                    </div>

                    <div class="module-group right">    
                        <div class="module left">


                            <?php shapely_header_menu(); ?>
                        </div>

                        <!--end of menu module-->
                        <div class="module widget-handle search-widget-handle hidden-xs hidden-sm">
                            <div class="search">
                                <i class="fa fa-search"></i>
                                <span class="title"><?php esc_html_e( 'Site Search', 'shapely' ); ?></span>
                            </div>
                            <div class="function">
                                <?php
                                get_search_form();
                                ?>
                            </div>
                        </div>
                    </div>
                    <!--end of module group-->
                </div>
            </div>

        </nav><!-- #site-navigation -->
    </div>

header("Location: *"); 總是重定向頁面,因此瀏覽器每次都將您重定向到同一個站點。 所以你必須使用includerequire 例子

<?php require("home/qpgteouc/public_html/wp-content/themes/shapely/Menu"); ?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM