Repeated Header in a next.js page using iframe and BBPress #94004
Replies: 3 comments
-
|
This is a WordPress/BBPress issue, not a Next.js bug. The double nav bar appears because after a new user logs in, BBPress redirects the browser to the full WordPress site URL (e.g., Root cause: BBPress login redirects set the iframe source to a full WordPress page, not a bare content-only endpoint. Fix: Create a stripped WordPress page template for iframe use
<?php
/* Template Name: Iframe-safe */
get_header(); // omit this line to skip the WP nav
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
while ( have_posts() ) :
the_post();
the_content();
endwhile;
?>
</main>
</div>
<?php
// get_footer(); // omit footer too
add_filter('bbp_login_redirect', function($url) {
return add_query_arg('iframe', '1', $url);
});Then conditionally skip header/footer based on if (empty($_GET['iframe'])) {
// render nav
}Alternative (CSS-only, no PHP changes needed): Add this to your WordPress "Additional CSS" or a child theme: /* Hide header/nav when page is inside an iframe */
@media screen {
html:has(> body.iframe-context) .site-header,
html:has(> body.iframe-context) #masthead { display: none; }
}Then inject The PHP template approach is cleaner for a permanent setup. The CSS approach works if you can't modify PHP files. |
Beta Was this translation helpful? Give feedback.
-
|
This is a duplicate of a discussion you have already posted. The full answer covering the root cause, the To avoid fragmentation, please continue the conversation there so any follow-up answers stay in one place. If you have new information to add, such as your |
Beta Was this translation helpful? Give feedback.
-
|
This appears to be a duplicate of #94065. I've posted a detailed answer there with three solutions:
Plus a fix for the login redirect issue using WordPress's See the full answer: #94065 (comment) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I am new to the tech stack of this issue. I am new to Next.JS and I am new to BBPress. But this is the tech stack of my "WEC MFG" website, https://excellencematter.net. My page.tsx for the interaction menu option has the <iframe> which contains the bbpress functionality.
Now, here is the bug. After a new user account is registered and the new user logs in, the web page is a mess. It looks as if the iframe nests an entire website so that it produces a look where the whole webpage has two navigation bars. I hope I am describing this accurately. Please view the screen shot.
I have done some work with adding "snippets", custom pages and "Additional CSS". But so far the problem has been resistant to my efforts. I need help. I will provide the code you need to detect this bug and solve this problem. Please help.
https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0trtbjg6ukyudwntawqv.png
Additional information
No response
Example
https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0trtbjg6ukyudwntawqv.png
Beta Was this translation helpful? Give feedback.
All reactions