Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #586020

    Hi,

    is there a way to hide all password protected posts from the loop, i.e. from appearing in the blog, the archive, in the sidebar widget “latest posts” for example and from the RSS feed?
    These posts are simply password protected by WordPress, no member plugin or such things.

    Any idea please?
    Thank you!

    #586108

    Hey COLORIT!

    you would need a plugin for such function.

    Cheers!
    Andy

    #586132

    Hi Andy,

    Isn’t there any possibility, to add something to the functions.php instead a plugin?

    #586922

    Hey!

    Please add this in the functions.php file:

    function avf_password_post_filter( $where = '' ) {
        if (!is_single() && !is_admin()) {
            $where .= " AND post_password = ''";
        }
        return $where;
    }
    add_filter( 'posts_where', 'avf_password_post_filter' );

    Regards,
    Ismael

    #635592

    sorry for the delay, but your snippet works fine, thanks a lot!

    #635754

    Hi Chris,

    Great, glad we could help :-)

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.