To check post with post status private
, you could run the following:
if (get_post_status() == 'private' && is_user_logged_in()) {
// it's private and user is logged in, do stuff
} elseif (get_post_status() == 'draft') {
// it's draft, do stuff
} else {
// it's something else, do stuff
}
Or, in your current setup, you can simply only display published posts via:
if (get_post_status() == 'publish') {
// it's published, do stuff
$this->render();
}
You can learn more about post statuses via the codex page.
Related Posts:
- Auto-generated posts not showing in backend (but being counted!)
- Update postmeta Parent when post_status child change
- How to define which register_post_status goes to which register_post_type?
- Published post auto change status to pending after 90 days
- Show custom post status when logged out
- edit.php all post not working
- Custom Post Status & Taxonomies
- WP_Query Pagination on single-custom.php
- Restrict custom post type to only site administrator role
- How to force one column layout on custom post type edit page?
- WordPress REST Create Post of Custom Type
- Limit the post for differents custom post type in the same wp_query
- taxonomy list display custom post count
- Assigning a role to a specific custom post type (and ignoring other post types)
- Display posts in random post types
- Custom Post Type by user
- How to create posts (not post template) to be displayed on projects page?
- same archive template for different custom post
- How to make post sticky in the admin page?
- How can I show a custom post type for users in the authors.php file?
- Blog page showing same content as homepage
- Need help targeting a custom post type with conditional tags
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- How to limit post of custom post status?
- Show the same Article Available in Other Categories
- Show custom post type filtered by category
- Display random posts, but omit the post it is on?
- Disable block with taxonomies at post page
- Get latest 3 posts from multiple CPT in one query
- Meta query for custom post type ignored in main query
- Hiding posts by other users and non-logged in
- Get related posts of child term of custom post type
- Removing all post statuses from a Custom Post Type
- 2 Different Custom Post Types in Submenu
- How to assign classes to all elements?
- How can I show 1 featured post in a styled element, and the next few below differently styled
- Reworking function for counting custom post type posts count
- wp_insert_post wrong post type [closed]
- Can I change my post type to anything and my site still work?
- How to Display Posts From Category Within a Custom Taxonomy?
- display posts of custom post type with custom taxonomy
- Automatically update slug with latest title within custom post type [duplicate]
- How to Query in WordPress which shows Alphabetic Posts?
- Post Query not working
- How to filter url on post submission?
- Different structure/content for posts from a custom post type
- creating files for displaying different custom post type posts with paging
- is it possible in a custom post, create custom fields as well whitin?
- custom taxonomy listing returns no posts
- How to controll the Posts post type and general wondering about WP data structure
- Display author box on just certain category posts?
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Am I mixing up the concept of posts pages and categories?
- Display custom post counts for author , not default posts
- Building a Data Intensive Website with WordPress
- If/Else child list for Custom Post Type single template within loop?
- redirect after submiting post for review
- Display all Categories except ones with a specific parent
- How to achieve a multi-taxomony layout with posts?
- i need to have a tab with gategory post
- Custom Post type to Woocommerce Product type
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- Enforcing a rigid reusable template structure for similar posts?
- Auto delete pages/posts without views
- WordPress retrieving $post based on random key in $_POST
- Sql Update CPT from publish to draft and particular custom field
- minimize wp_query call to database
- Post display in separate page [duplicate]
- User Archive page for Custom Post Type – Pagination Issue
- Limit posts per page depending on the size of a div?
- Delete Post by User
- Custom post Query and WordPress Post Query Clash
- Setting up a page to house certain types of posts
- Multiple Custom Post Type with different Taxonomies
- Links Image in “Catalog” Page to Posts
- Only show current category post
- WordPress Contents Migration
- Filter By Term Not Working – Custom Post Type
- Problem to get the link of the default ‘post’ post type like the orther custom types
- how to display notifications in the wordpress menu when a new post is published
- Editor role isn’t seeing specific post type posts with only post_type parameter
- Featured image in custom post is being disabled
- How to set class to “current-page” on the currently viewed single post within a CPT
- Getting wrong ID
- How can draft post after 1 year
- How to make post page unique and show it on home page?
- How to create content automatically when a post is published?
- query_post causes the posts to be loaded twice on load more posts
- Query Only Show Text on Posts With Certain Taxonomy Tag
- Query Posts From Multiple Post Types
- WP Build-In Post selector for CPT
- How to make a template for a specific post of a custom post type?
- How to hide home title on pages and posts?
- How do I hide single category post on my post page
- Front end post or photo or both
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- How to make a non-public post on wordpress approval?
- How Do I Add a Custom Post Type URL to Content?
- is therer any wordpress function to retrieve a specific html element from post content
- Post content in bootstrap modal