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
- Update Post Meta for a logged in user
- Add custom field to Posts and sort by it
- Add custom post type settings to wordress default posts
- Featured image overlay when changing post status
- Get related posts of child term of custom post type
- Two Custom Post Types Many to Many Relationship
- Problem with displaying posts in the CPT category
- JS innerhtml changing style when using AJAX
- Custom post type suppress transition from future to publish
- Show titles, date of all posts on single category page
- Side effects of Script and Iframe in post
- How to change the post type a theme shows by default?
- Set a checkmark in a category based on a URL-parameter
- Several post types on WP Query by tag and taxonomy
- No Permission to add new Page, Post or CPT with Admin role
- custom post type category count shortcode
- Portfolio Page for Classic Posts
- Add post location with mile radius allowing search
- Get the category from custom post type
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- Set up post page like JAMA articles
- Custom Post Slug same as Parents Category Slug
- Shortcode not working with post counter
- Changing default ‘posts’ parameters with register_post_type_args
- Admin Column does not populate with data
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Prioritize posts in query by meta keys?
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Removing all post statuses from a Custom Post Type
- Allow users to create posts without logging in?
- How to get all tags of a custom post type by id
- Add custom post type drafts to RSS feed
- Load Next Posts With AJAX not working with custom post type
- Limit the post for differents custom post type in the same wp_query
- 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
- Some posts from custom post type to subdomains
- How can i create an custom post template for an specific post category? [closed]
- How to sort posts in a custom post type by title in ascending order by default?
- WP the_posts() on single-cars.php get category link
- Conditional for a Single Post That Belongs to a Category?
- $post not working working in AJAX plugin with custom post type
- Permalink misbehaving in Custom Post Types
- Check post on publish for blank title
- how to check if custom post title exists or not?
- Different Limit number of post on different archive page
- How to change “post_class()” for a custom post type?
- Modify previous and next post links to current Authors Other posts
- Reworking function for counting custom post type posts count
- Create new custom post and post category of same name
- wordpress remove views from action links in a custom post
- Load Next WordPress Posts With AJAX?
- Help With Warning on creating new Post types?
- help
- Including link to custom post type in ‘wp_list_pages’ function
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Is it a good idea to add a column to the posts table?
- wp_insert_post wrong post type [closed]
- Multiple pages per post (not pagination)
- If there is only one post (show elements) else (show other elements)
- Custom post types and ‘new WP_Query’
- Can I change my post type to anything and my site still work?
- Programmatically change post visibility on save_post action return a 500
- Variable not working in WP_Query
- Display an authors post on a single page only when they are logged in
- What’s an efficient way to change the post status of many posts at once?
- How to Display Posts From Category Within a Custom Taxonomy?
- Showing custom post type categories in the menu
- Display Only Certain Category In a Custom Page Template
- How to Make infinite loop of post
- WP_Query with custom post type ID
- Creating separate feeds for custom post types
- Get_the_terms restrict output
- Custom post type menu
- Stores category posts in an array
- Query within a foreach within a query (queryception)
- How to implement a different permalink structure for custom post type?
- wordpress lists similar type of posts in a custom post type
- Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin
- I can no longer post or even save a draft, getting the error “A post type mismatch has been detected.”
- How to retrieve all wordpress posts (specific type) inside a function in php?
- Generate new post from email
- YOAST SEO won’t work on custom post type archive [closed]
- Auto post creation
- Batch Extract Date from post title and put into ACF custom field
- WordPress notification if new post published
- display posts of custom post type with custom taxonomy
- How to handle new post from API request?
- Automatically update slug with latest title within custom post type [duplicate]
- Modifying the default post from wordpress
- Dynamic pages for linked categories and content
- Separate Content from gallery (custom post type)