0
當有人訪問我的WordPress網站中的特定頁面時,我想顯示另一個網站的全屏iframe。它必須完全覆蓋我的網頁,所以看起來好像用戶現在在另一個網站上(url仍然是我的)。如何在WP頁面上顯示全屏iframe?
我該怎麼做?有沒有可能的插件?
P. S.我知道如何編碼,但我從來沒有開發過任何關於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文件? –
它會在您的wordpress主題目錄中。 這是wp-content/themes/ur-theme/header.php – Ashkar
ehm,你能否在第一篇文章中檢查我的代碼?我真的不知道該把它放在哪裏。使用最新的代碼,它似乎不起作用。 –