简体   繁体   English

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

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

I'm trying to solve a problem regarding how to animate font awesome menu bars to toggle click.我正在尝试解决有关如何为字体真棒菜单栏设置动画以切换单击的问题。

I haven't been able to but, to get around it, I've created a file in my theme folder and called it Menu Bars .我没能做到,但为了解决这个问题,我在我的主题文件夹中创建了一个文件并将其命名为Menu Bars In this file I placed the following code:在这个文件中,我放置了以下代码:

<!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>

Then I looked in my header.php and replaced <i class="fa fa-bars"></i> with然后我查看了我的 header.php 并将<i class="fa fa-bars"></i>替换为

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

I assumed this would redirect to this file `Menu Bars in location:我假设这会重定向到这个文件`菜单栏的位置:

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

and execute the file, so creating the menu bars animation which I want.并执行文件,创建我想要的菜单栏 animation。

What actually happened was that the site refused to load on grounds of too many redirects .实际发生的情况是该站点以too many redirects为由拒绝加载。

Is what I'm trying to do possible and if so what do i need to do?我正在尝试做的事情是否可行,如果可以,我需要做什么?

Here's what i have so far after helpful suggestions but still not working.这是我在提出有用的建议后到目前为止所拥有的,但仍然无法正常工作。

<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: *"); redirecting the page always and so the browser redirecting you everythime to the same site.总是重定向页面,因此浏览器每次都将您重定向到同一个站点。 So you have to use include or require .所以你必须使用includerequire Example例子

<?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