Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Commit

Permalink
feat(Features/HideProtectedPosts): Remove password protected posts fr…
Browse files Browse the repository at this point in the history
…om query (#205)

* feat(HideProtectedPosts): Remove from query password protected posts

Remove from query password protected posts if not in a singular page or in admin

* feat(Features/HideProtectedPosts): Added a readme.md file
  • Loading branch information
vandebled authored and Doğa Gürdal committed Jun 6, 2017
1 parent b7f3c9c commit 6f4b531
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Features/HideProtectedPosts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Hide Protected Posts (Flynt Feature)

Hide password protected posts from listings when using the loop or `get_posts`.
9 changes: 9 additions & 0 deletions Features/HideProtectedPosts/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Flynt\Features\HideProtectedPosts;

add_action('pre_get_posts', function ($query) {
if (!$query->is_singular() && !is_admin()) {
$query->set('has_password', false);
}
});
3 changes: 3 additions & 0 deletions lib/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ function initTheme()
// google analytics
add_theme_support('flynt-google-analytics');

// hide protected posts
add_theme_support('flynt-hide-protected-posts');

// WP Stuff
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
Expand Down

0 comments on commit 6f4b531

Please sign in to comment.