WordPress.org

Forums

Protected Page with Posts : Password form not showing (1 post)

  1. MirkoE
    Member
    Posted 2 years ago #

    Hello,

    im trying to add a password protected page to my theme on which I want to show posts, that only users who (obviously) know the password can see.

    I've searched and tried for a few hours now and the best solution I found is this

    <?php if(!empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {
    	the_content(); // this will be used to display password form
    }
    
    if (isset($_COOKIE['wp-postpass_' . COOKIEHASH]) && $_COOKIE['wp-postpass_' . COOKIEHASH] == $post->post_password) {
    
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$args= array(
    		'category_name' => 'Secret Stuff',
    		'paged' => $paged
    	);
    	query_posts($args);
    
    	[ custom query here ]
    
    	[ usual Loop here ]
    }?>

    But this doesn't seem to work in 3.5. The Password Form doesn't show on the protected page. Can anyone help and tell me what is wrong?

    Thanks
    MirkoE

Topic Closed

This topic has been closed to new replies.

About this Topic