• Hello— I have a weblog filled with posts of videos for which I want to restrict access, and I want a single password for the weblog page. I’m not worried about anyone figuring out the exact URLs of the video files, so I’m not worried about high security— low security is fine. The obvious thing is to use the built in password tool on on the page editor, but to my horror after I promised my client I could protect the blog I find that this is the one page you *can’t* protect?!

    I found a category password protector plugin but it doesn’t protect the blog page, it only applies a more or less global password to all the designated posts… so the blog page is ugly and unusable (a user sees no thumbnails, and has to unlock each video). There are plenty of plugins which will lock down the whole site, but that’s no good. I’ve spent many hours on this and early on thought I found something that makes sense here: https://wordpress.com/forums/topic/password-protected-page-not-working/

    “Hi,
    You cannot use the default wordpress setting to password protect your static page that you then set as your posts page if you follow.

    You need to set a custom template for your posts page.”

    …The user proceeds to suggest code, which I tried but couldn’t get to work since I don’t understand the php too well (note that this solution was given for a WordPress.com question, but was marked down as being inapplicable as being a .org solution). I could combine the code well enough and get a page to render, but the password field would not appear (the password prompt does though). And I was having trouble with code redundancy, and isolating the code rendering the naked content from the code that generates the password stuff (I had another “clean” non authenticated browser as a test).

    Is there not some easier way to get this accomplished? I’m wanting to avoid making some non-dynamic static pages that I have to just keep adding static links and pagination to, since that’s poor use of time, and defeats the purpose of WP. Thank you in advance!

    • This topic was modified 4 years, 11 months ago by Jan Dembowski.
Viewing 1 replies (of 1 total)
  • Thread Starter Elliott Wall

    (@elliott-wall)

    I would be perfectly happy with pass protecting the category page that shows the videos— it doesn’t have to be the main blog page, if that helps.

    The index.php for my theme is:

    <?php 
    
    get_header();
    
    if ( is_home() && !is_paged() ) {
    
    	if ( savona_options( 'featured_slider_label' ) === true || savona_options( 'featured_links_label' ) === true ) {
    		// Featured Slider, Carousel
    		if ( savona_options( 'featured_slider_label' ) === true ) {
    			get_template_part( 'templates/header/featured', 'slider' );
    		}
    
    		// Featured Links, Banners
    		if ( savona_options( 'featured_links_label' ) === true ) {
    			get_template_part( 'templates/header/featured', 'links' ); 
    		}
    	}
    }
    
    ?>
    
    <div class="main-content clear-fix<?php echo esc_attr(savona_options( 'general_content_width' )) === 'boxed' ? ' boxed-wrapper': ''; ?>" data-layout="<?php echo esc_attr( savona_page_layout() ); ?>" data-sidebar-sticky="<?php echo esc_attr( savona_options( 'general_sidebar_sticky' )  ); ?>">
    	
    	<?php
    	
    	// Sidebar Left
    	get_template_part( 'templates/sidebars/sidebar', 'left' ); 
    
    	// Blog Grid Wrapper
    	get_template_part( 'templates/grid/blog', 'grid' );
    
    	// Sidebar Right
    	get_template_part( 'templates/sidebars/sidebar', 'right' ); 
    
    	?>
    
    </div>
    
    <?php get_footer(); ?>
    

    And if I understand correctly from the forum comment I mentioned above, I wanted to integrate that into this:

    <?php
    /*
    Template Name: postspage
    */
    ?>
    <?php get_header(); ?>
    <?php
    $lastposts = get_posts();
    foreach($lastposts as $post) :
    setup_postdata($post);
    ?>
    <div class=”item”>
    <h2><?php the_title(); ?></h2>
    <p class=”date”><?php the_time(‘j.m.Y’) ?></p>
    <?php the_content(); ?>
    </div>
    <?php endforeach; ?>
    <?php get_sidebar(); ?>
    <?php include (TEMPLATEPATH . “/footer.php”); ?>

    Since it’s above my skill level and the pay grade of this gig to spend much further time on this, and it being a problem I’ll never have to face again, I probably can’t really be looking into how every hook works. So the results of my efforts thus far are probably pretty comedic— I have no idea what I’m doing! ??

    <?php
    /*
    Template Name: postspage
    */
    ?>
    <?php 
    get_header();
    if ( is_home() && !is_paged() ) {
    
    	if ( savona_options( 'featured_slider_label' ) === true || savona_options( 'featured_links_label' ) === true ) {
    		// Featured Slider, Carousel
    		if ( savona_options( 'featured_slider_label' ) === true ) {
    			get_template_part( 'templates/header/featured', 'slider' );
    		}
    
    		// Featured Links, Banners
    		if ( savona_options( 'featured_links_label' ) === true ) {
    			get_template_part( 'templates/header/featured', 'links' ); 
    		}
    	}
    }
    ?>
    
    <div class="main-content clear-fix<?php echo esc_attr(savona_options( 'general_content_width' )) === 'boxed' ? ' boxed-wrapper': ''; ?>" data-layout="<?php echo esc_attr( savona_page_layout() ); ?>" data-sidebar-sticky="<?php echo esc_attr( savona_options( 'general_sidebar_sticky' )  ); ?>">
    	
    <?php
    $lastposts = get_posts();
    foreach($lastposts as $post) :
    setup_postdata($post);
    ?>
    <div class=”item”>
    <h2><?php the_title(); ?></h2>
    <p class=”date”><?php the_time(‘j.m.Y’) ?></p>
    <?php the_content(); ?>
    </div>
    <?php endforeach; ?>
    	<?php
    	// Sidebar Left
    	get_template_part( 'templates/sidebars/sidebar', 'left' ); 
    
    	// Blog Grid Wrapper
    	get_template_part( 'templates/grid/blog', 'grid' );
    
    	// Sidebar Right
    	get_template_part( 'templates/sidebars/sidebar', 'right' ); 
    	?>
    </div>
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Password protect blog/posts page?’ is closed to new replies.