If you want both logged in and non-logged in user to see the same thing then you only want ‘published’ post status, at least it doesn’t make sense to me to show ‘private’ posts to non-logged in users. Alter you query to include that condition.
$most_recent_sticky_post = new WP_Query(
array(
'post_status' => array( 'publish' ),
// Only sticky posts
'post__in' => $sticky,
// Treat them as sticky posts
'ignore_sticky_posts' => 1,
// Order by date to get the most recently published sticky post
'orderby' => date,
// Get only the one most recent
'posts_per_page' => 1
)
);
ignore_sticky_posts
, when true
as you have it, treats sticky posts like ordinary posts, which is not what your code comment says but I think that is what you mean.
Related Posts:
- How to restrict attachment download to a specific user?
- How to add “Stick this post to the front page” to front end?
- How to make my front page display only the most recent sticky post, plus usual widgets?
- How do I show sticky posts on a static front page that also contains content?
- Using JWT to authenticate a user with an external system?
- Allow anonymous user to access Themes Customizer
- Is there an existing capability to allow editing of only pre-existing pages? If not, a good way to implement this?
- How to make user inactive by default while registering?
- How to set privilege to wordpress subscriber for private page
- authenticate user without password from email activation link [duplicate]
- User Access Manager plugin
- How to block access to blog-page for users not logged in?
- How can we Restrict to access a certain wordpress page to all ip address except some which we allow
- Restrict post to user_id
- add_option_page capability behaving strange
- Access denied on Published Pages but not on WordPress /wp-admin/
- Allow non logged users to visit only login page and password reset page
- How can I allow users to make groupings of posts
- Is user listing on wordpress private?
- How to restrict logged user to view only certain pages?
- Limit post display to post authors and create an exception for specific pages
- Include sticky posts on the static page front page
- How to “Global Ignore” / “Hell Ban” someone, restrict post visibility to the author only?
- Conditional menu for registerd users/guests (Genesis framework)
- How can I create an upload page for (and only visible to) specific users?
- Exclude all sticky posts front page twenty twelve
- remove wp admin menu by customer user role
- Custom Roles for access to specific term(s)
- ‘post’ only for editor and administrator
- Access denied error when logged in as admin
- Disable all admin UI access to authors (except to custom post type add, edit and modify)
- Hide all pages except landing page
- How to restrict access to a page?
- How can I change access permissions across many pages?
- How do I get the access type in WordPress?
- Profiles site with access levels
- User access control in sidebar archive and categorires
- Plugins that restrict access based on user group/roles
- Restrict access for wp-admin panel
- Specify the level of access to different pages at the time of user creation
- When add analytics script, wordpress user login not working
- Hide WordPress “wp-admin” dashboard to User IDS
- I cannot access but but wp-admin works normally
- about visibility in wordpress regarding of roles
- Can access main URL and Dashboard but not any posts or pages [closed]
- How to List only the users created by a particular user
- How to enable to the user send content and save as draft entry?
- How to give members access to their own protected page?
- Use WordPress engine for user registration and management
- How to make future posts visible to selected visitors without login
- Add existing user as administrator
- Split post edit screen into sub-edit screens for users, is this good or bad, and is it possible?
- Suggestions for allowing basic users to view their own posts?
- How to display only sticky posts on my automatically generated front page?
- How to restrict posts only from a certain category
- Two users attempt to modify a page
- When to use is_home() vs is_front_page()?
- Allow member to have access to custom post type only. Permission to only edit their own posts
- How do I create a custom role capability?
- Sticky Posts exceed posts per page limit
- How to enable suggested edits?
- With Rest V2 (WP4.7) how does one restrict certain RESTFUL verbs?
- Using pre_get_posts on true pages and static front pages
- How to programatically change username (user_login)?
- How to check if user is in back end?
- Programmatically set page_on_front
- why ignore_sticky_posts in sticky post query
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- How can I create a “Read More” link using the_excerpt() on a static front page?
- How to restrict access to uploaded files?
- wp_update_user not updating
- is_front_page() malfunction?
- Allowing users to edit only their page and nobody else’s
- Can an admin check passwords of registered users?
- HTTPS leads to Sorry, you are not allowed to access this page
- How do I fetch the static front page using the REST API?
- Troubleshooting a “You do not have sufficient permissions to access this page” error
- Code to make a post sticky
- Restrict admin access to certain pages for certain users
- How can I hide a category from Contributors in the edit/add new post screen?
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- Ways to have multiple front-page.php templates that can be swapped out?
- WP_Query: Why is sticky post not first item in loop?
- How to assign specific users the capability to edit specific pages / posts / custom post types
- Hide Admin Menu for Specific User ID who has administrator Role
- is_front_page only works in theme file, and does not work in functions.php
- Query *only* sticky posts
- What is the correct method for determining ‘is_front_page’ when using filters such as ‘pre_get_posts’ and ‘posts_where’?
- Exclude sticky post from main query?
- How to get all capabilities of an existing user role
- Allowing an email as the username?
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- Limit access to posts/pages by user roles
- Show Sticky Posts in Category Archive
- Set sticky posts schedule (Automatic)
- Allowing specific users to only add posts using certain custom taxomy terms
- Category page doesn’t use category.php, instead it redirects to homepage
- Show all sticky posts, WITH pagination
- Sticky Posts & Posts Per Page [closed]
- Is WordPress’ is_user_logged_in() secure?