Hide A Post
A WordPress plugin to hide posts from non-Administrators on the site, in search, and in WordPress admin by category.
Install in
Hide A Post lets Administrators keep selected categories—as well as default-category (Uncategorized) posts authored by Administrators—hidden from Editors and other non-Administrator users across the site, search results, WordPress admin, and direct REST API / post-ID access.
Hide A Post Settings
Go to Settings Hide A Post and check the categories you want hidden from non-Administrators (for example, Awesome and Spicy).
Example Posts (seen by Administrators)
- Tomato (Owner: Administrator, Categories: Fruit, Red)
- Potato (Owner: Administrator, Categories: Vegetable, White)
- Broccoli (Owner: Administrator, Categories: Vegetable, Green)
- Mushrooms (Owner: Administrator, Categories: Vegetable, White, Awesome) – Hidden from non-Administrators via “Awesome”.
- Apple (Owner: Administrator, Categories: Fruit, Red)
- Pear (Owner: Administrator, Categories: Fruit, Green, Awesome) – Hidden from non-Administrators via “Awesome”.
- Peppers (Owner: Administrator, Categories: Vegetable, Green, Spicy) – Hidden from non-Administrators via “Spicy”.
- Peach (Owner: Administrator, Categories: Uncategorized) – Hidden from non-Administrators as an Administrator-authored default-category post.
- Blueberries (Owner: Administrator, Categories: Fruit, Blue, Uncategorized) – Still hidden while in the default category.
- Raspberries (Owner: Editor, Categories: Fruit, Red, Awesome) – Hidden from non-Administrators via “Awesome”; visible to Administrators.
Example Posts (seen by Editors)
- Tomato (Owner: Administrator, Categories: Fruit, Red)
- Potato (Owner: Administrator, Categories: Vegetable, White)
- Broccoli (Owner: Administrator, Categories: Vegetable, Green)
- Apple (Owner: Administrator, Categories: Fruit, Red)
About the plugin
We wanted to use WordPress with our tabletop gaming group. This enables everyone to collaborate on content creation while allowing the Dungeon Master to keep certain “secrets” hidden.
Written by Joobi from the project's own listing. See the source page
2.0.0
- Modernized plugin architecture for WordPress 7.0+ (tested up to 7.1) and PHP 7.4–8.5.
- Fixed fatal
TypeErrorcrash when listing posts via WP-CLI. - Replaced comma-separated category text input with hierarchical category checkboxes on the settings screen.
- Replaced hardcoded
wp_table prefixes and raw SQL interpolation with dynamic$wpdbtable names, qualified columns, and parameterizedNOT EXISTSqueries via$wpdb->prepare(). - Blocked direct access to hidden posts by ID: capabilities (
map_meta_cap, includingWP_Postarguments), REST API reads of posts and their sub-resources (404 before the endpoint runs), revisions, oEmbed, old-slug redirects, and canonical/404 slug-guess redirects. - Hid comments on hidden posts from comment queries, the REST API, the comments feed, and Recent Comments, and closed new comments on them.
- Filtered classic menus and Navigation blocks, including nested submenus and REST
menu-itemsandwp_navigationresponses, so links to hidden posts are not shown to non-Administrators (stored menus are not changed). - Redacted hidden post titles read by ID (such as Media Library parent labels) to “(Private post)” for non-Administrators.
- Blocked the per-post comments admin screen (
edit-comments.php?p=) for hidden posts. - Scoped Empty Trash to the posts the current user can see.
- Blocked non-Administrators from deleting hidden categories, including through bulk category deletion.
- Linked attachments of hidden posts by
?attachment_id=so the parent post’s slug is not exposed. - Excluded hidden posts from previous/next post links,
wp_get_archives(), andget_posts()calls that usesuppress_filters. - Treated every user with the
manage_optionscapability (plus Super Admins on Multisite) as an Administrator for the default-category rule. - Removed deleted categories from the saved settings automatically.
- Added the
hap_user_can_view_hidden_posts,hap_should_filter_query,hap_hide_admin_default_category_posts, andhap_administrator_idsfilters. - Added PHPUnit integration tests (single site and Multisite) to CI.
- Replaced deprecated
screen_icon()and role-name capability checks with modern Settings API markup andmanage_optionscapability checks. - Moved option cleanup from deactivation hook to
uninstall.phpso deactivating the plugin preserves saved settings. - Used WordPress’s
default_categoryoption instead of hardcoding the English string “Uncategorized”.
1.1
- Enhanced code to allow for more than one administrator.
- Improved SQL statements.
- Fixed bug with duplicate posts being displayed.
1.0
- Initial release.
Follow this listing's changes (Atom feed)