Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Password Protected Post – Hide Sidebar

Home / Forums / Kadence Theme / Password Protected Post – Hide Sidebar

This topic is: Resolved
[Resolved]
Posted in: Kadence Theme
April 15, 2024 at 8:43 pm

I have my posts setup with a simple password on each post for specific users. In the post, I have the layout set to content with 1 sidebar. In the side bar I have the table of contents block.

Before the user types in their password, you can still see the sidebar on the front end.

Is there a way to hide the sidebar before the user enters in the password?

I tried this code, but didn’t work:

function hide_sidebar_for_protected_posts() {
if ( is_singular() && post_password_required() ) {
remove_action( 'get_sidebar', 'get_sidebar' );
}
}
add_action( 'template_redirect', 'hide_sidebar_for_protected_posts' );

Thanks in advance!

  • The forum ‘Kadence Theme’ is closed to new topics and replies.