• Hi there,

    Is there any easy way to password protect only portfolio (custom post types) items?

    Many thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter ArtGoddess

    (@artgoddess)

    I believe this code does the trick, but Custom Post Types are visible and it looks weird.

    Besides that, I am not sure if storing the password this way is safe or not.

    function passwordProtectPortfolio ( $post_object ) {
    
      if ( $post_object -> post_type != 'portfolio' ) {
        return;
      }
      $post_object -> post_password = 'yourDesiredPassword';
    }
    
    add_action( 'the_post', 'passwordProtectPortfolio' );
    • This reply was modified 3 years, 12 months ago by ArtGoddess.
Viewing 1 replies (of 1 total)
  • The topic ‘Password protect all portfolio items?’ is closed to new replies.