Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 如何在WP页面顶部显示全屏iframe?_Wordpress_Iframe_Custom Wordpress Pages_Iframe Resizer - Fatal编程技术网

Wordpress 如何在WP页面顶部显示全屏iframe?

Wordpress 如何在WP页面顶部显示全屏iframe?,wordpress,iframe,custom-wordpress-pages,iframe-resizer,Wordpress,Iframe,Custom Wordpress Pages,Iframe Resizer,当有人访问我的WordPress网站的某个特定页面时,我想在上面显示另一个网站的全屏iframe。它必须完全覆盖我的网页,所以它看起来就像用户现在在另一个网站上一样(url仍然是我的) 我该怎么做?可能有插件吗 另外,我知道如何编码,但我从未在WordPress上开发过任何东西。请具体说明:) 编辑: 正在尝试将iframe放在header.php上: <?php /** * The header for our theme. * * This is the template tha

当有人访问我的WordPress网站的某个特定页面时,我想在上面显示另一个网站的全屏iframe。它必须完全覆盖我的网页,所以它看起来就像用户现在在另一个网站上一样(url仍然是我的)

我该怎么做?可能有插件吗

另外,我知道如何编码,但我从未在WordPress上开发过任何东西。请具体说明:)

编辑: 正在尝试将iframe放在header.php上:

<?php
/**
 * The header for our theme.
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package staymore
 */

?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
    <?php
    // When user visits http://my-website.com/privacy-policy
            if(is_page('privacy-policy'))
            {?>
            <iframe src="http://google.com" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;">
            Your browser doesn't support iframes
        </iframe>
            <?}
    ?>
<div id="page" class="site">
    <a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'staymore' ); ?></a>

    <header id="masthead" class="site-header" role="banner">
        <div class="wrap">
        <div class="site-branding">
                <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
            <?php 

            $description = get_bloginfo( 'description', 'display' );
            if ( $description || is_customize_preview() ) : ?>
                <p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p>
            <?php
            endif; ?>
        </div><!-- .site-branding -->
        <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"></button>
        <nav id="site-navigation" class="main-navigation" role="navigation">
            <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_id' => 'primary-menu' ) ); ?>
        </nav><!-- #site-navigation -->

        </div>
    </header><!-- #masthead -->
    <div class="site-banner">
    <!-- #Header-image -->
        <?php if ( get_header_image() ) : ?>
    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
        <img src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="">
    </a>
    <?php endif; // End header image check. ?>  
    </div>
    <div id="content" class="site-content">
        <div class="wrap">


这很简单,首先请在
header.php
文件中放置一个条件标记来检查页面:

    <?php
        // When Page 42 (ID) is being displayed.
        if (is_page( 42 ))
        { ?>
         <iframe src="https://www.w3schools.com/html/html_iframe.asp" frameborder="0" scrolling="yes" seamless="seamless" style="display:block; width:100%; height:100vh;"></iframe>
     <?php   }    ?>


这个header.php文件在哪里?它将在wordpress主题目录中。这是wp content/themes/ur theme/header.phpehm,您能在第一次后期编辑中检查我的代码吗?我真的不知道该把它放在哪里。对于当前的代码,它似乎不起作用。我将header.php代码放在第一篇文章中,如果编辑不可见,尝试刷新页面OK,经过一些测试,我发现该代码确实将iframe放在网页上,但它不可见(我仅在页面源代码视图中看到)。此外,页面上的普通链接也变得不可访问
if (is_page('Contact')) {iframe code here}
if(is_page('about-us'))