Your function will never “get” $post
as this is not how functions work. Functions cannot pull anything into itself by itself. If you have debug turned on, you will get a definite bug notice that $post
in undefined…..
You would need to invoke the $post
global inside your function for anything to work that relies on the $post
global, so the following would work
function unlocked() {
global $post;
if(!empty($post->post_password) && !post_password_required()) {
echo 'unlocked icon reminding them this was protected and they put in their password already';
}
}
Related Posts:
- How to protect pages with double authentication: password + email (in custom field)
- How can I safely increase the character limit for post passwords?
- Is it possible to direct users to a certain post based on a password entered on the home page?
- Hide password protected posts in admin
- How to lock a post or page
- How to verify wp user password by sql query in wp? [closed]
- Remove password protected posts from default RSS feed
- Display password protected posts to logged in users
- Change the color of the Password Protected Post titles
- How do I check if a post is password protected?
- Using WP page password protection as defacto login
- Password-protected Posts lead to 404 Error
- How to check if post meta key exists or not in wordpress database
- Custom Post Types, slug, archive and SEO plugins
- Portable Post Links
- Related Posts by Multiple Tags?
- Action hook ‘wp’ firing twice… why?
- Dynamically update post title in admin page
- How can I display 7 posts on the home page, but 9 posts on the subsequent pages?
- WP REST API, query total posts in a category
- duplicate posts when trying to update a post using the wp_insert_post.
- Add custom field to all posts in specific category
- 404 error after publishing a post
- How to remove_filter that filters iframes in posts? [duplicate]
- Hiding by default specific post status on backend list?
- How to edit layout of a particular post format?
- Detect Post Type when publish_post is ran
- Showing Thumbnail from Previous and Next Posts
- WP_Query in functions.php overrides global $post object, even with wp_reset_query()
- How to automate filing a form as a user
- WP rest api returns 404 only when author param is used
- What Is meta_id In wp_postmeta?
- the_posts filter been called multiple time
- Direct link to “New post” in specific category?
- Disable most recent & view all (TABS) on nav-menu.php
- WP Bakery Load More Button loads the same posts
- How do I retrieve then print the currently viewed sub categories?
- WP Query – Posts Per Page not working in combination with category__in
- Apply a style for 4 blogs and another style for the next 4 blogs in wordpress blog page?
- Show posts by a custom post author
- Chrome + Ad Blocker hides the content of the post
- How to render taxonomy in loop of custom post_type
- Posting blog entries in screenplay format
- Blank page when saving edits on post
- Listing Specific Categories from Current Post with Depth
- Custom Post Type Rewrite To Include Parent Page(s)
- Getting only the URL of the post thumbnail
- outputting posts’ taxonomies: cant get ‘get_the_taxonomies’ working
- Displaying posts that belong to a specific author
- Query for first 3 posts to change the look and feel
- Getting blog pagination to work on page set as front page
- How to identify and hide/remove an element from a WordPress page [closed]
- Navigate through the posts using keyboard arrows
- unique post in “$args” of wp_query display more than one post
- New Posts and Pages Won’t Save
- Why excerpt is Displaying same in Random Posts list
- Is there a way getting post fields using `transition_post_status`
- Show posts on front page only
- Get featured image on hover of post title [closed]
- How get top post view for today for today post
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- Why my meta boxes won’t show in front post page?
- Authors’ Links on Homepage Not Going to Author Post Pages
- My post does not show up
- Display Current Posts Category (with the most posts)?
- How can I add random alphabets in wordpress permalink posts structure
- AWS usage queries
- Create a List of Widgets, where each widget holds three attributes
- Filter posts by month (dropdown)
- How to fetch courses in all languages in WordPress?
- Redirect old Posts URL to new URL
- Create a tree with categories with get_posts()
- Use posts from old db by changing prefix
- Center crop the feature image
- Display Custom Post Category Count & WordPress Category Count Using Shortcode
- Override default post type ‘post’
- ‘posts’ table should not store the absolute image path
- How to make a page show posts only from specific categories without editing php files
- Display post on main page with thumbnail
- Redirecting user to a page when there is no content?
- How can I alternate styling of images in a post? [closed]
- Custom Single Post Type not referring to single-post-type.php File
- Display iframe or embeded posts on homepage
- index.php is only displaying current month’s posts?
- How can I use the “Your latest posts” as a template?
- Query to get data of a post, if in category?
- Order posts by custom field
- “Current” class on a singular page menu item with custom post types?
- Continuous listing from a custom field
- get next/previous post name
- Add class name of content, Hypernate doesn’t work to IE and Chrome
- How do I display the next 3 posts in the sidebar?
- 2 tick boxes appearing below comments
- Issue with wordpress pagination: last 2 posts show again on second page
- Extra Theme – Fit image inside of Featured Post Slider
- Stripping tag from elements in post
- Polylang – display one post into 3 categories with different lang [closed]
- How can I show the positive and negative comments for a same post separately?
- How to make the Post Author name fixed as “Editorial Staff” even if there are multiple authors?
- Trying to create parent for post. I need some help. Thanks