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
- How do I create a custom role capability?
- Sticky Posts exceed posts per page limit
- How to programatically change username (user_login)?
- Filter front page posts by category
- How can I hide media library images from general users?
- Sticky posts on home page, search, tag and archives without plugin
- Unable to load static front page on home url
- How to set a custom post type post as static front page?
- if role is logged in then do something
- Custom background for the index page only?
- Front end user meta options for users
- How to make all posts in a category “unsticky”?
- Making a Custom Post type only visible to non-users via a specific link
- WP Multisite Static Frontpage
- Protect custom php file with login
- How to make post sticky in the admin page?
- Disable front-page.php template
- Arrange posts by date in front page
- Changed site URL and now my Front Page doesn’t display correctly
- How to Display a Plugin function (content) on frontpage using index.php
- I’d like to cycle through existing posts in a post type, showing one per day ordered by title, and starting over when the last is reached
- style.css doesn’t load on the home page when front-page.php activated (using stock theme)
- Sticky posts not working when a specific category is set
- How to display the posts and news in front page?
- How to Find the Page the Front Page is Using?
- My custom template page not loading content inside it?
- I’m not able to get access to $wpdb [duplicate]
- How to check a post is sticky or not yet?
- How can I access string value in an array?
- How to restrict an admin page, if the user is not superadmin?
- Showing “best posts” in front page
- Make posts_per_page value the same on all pages
- Is WordPress secure enough for a multi-user article directory?
- is_front_page use in sidebar.php
- How to generate expiring URL of the page?
- Email post to submitter
- Make pagination work as a carousel (custom query)
- How do I restrict a second admin certain access?
- How to display only sticky posts on category pages?
- throttle/limit a logged in user’s http requests to specific page on a per day basis
- Categories with post from child categories on front page
- Font Page overrides rewrites
- No posts on front page
- How to block external download link access if visitor not referred from WP?