If you’re just trying to display different content to logged-in vs. logged-out users, I’d recommend using the the_content
filter.
add_filter( 'the_content', 'wpse_387084_content_selector' );
function wpse_387084_content_selector( $content ) {
if ( is_front_page() && is_user_logged_in() ) {
$page = get_post( 2516 );
$content = $page->post_content;
}
return $content;
}
The above code assumes that you’ve set the “Page on Front” to the page with ID 2
, and that’s what you want to show to unauthenticated users.
Related Posts:
- Programmatically set page_on_front
- How to make my front page display only the most recent sticky post, plus usual widgets?
- How do I set the front page programmatically?
- Unable to load static front page on home url
- Custom background for the index page only?
- Load front-page.php from subfolder
- Can you select a post as the front page or only pages?
- Can’t edit front page of website [closed]
- How can I make WordPress serve homepage to different URL?
- How to block access to blog-page for users not logged in?
- Pagination not Working on only Front page on latest verson of WordPress
- Do I need an empty page for a different blog page?
- Showing option when page is frontpage
- Is it possible for homepage in Twentyseventeen theme to look like a standard page?
- WordPress site front page fails to load in IE
- Home/front page won’t display content after a form is submitted
- how to create a static front page for my blog in wordpress
- Home link in the homepage of my wordpress does not show my blog posts
- WordPress, how to figure out how to edit front page
- How to set a static html front page
- NON Static-Front Page
- Front Page Settings
- What code controls the animation for the front-page header in TwentySeventeen
- Setting index.php as a static home page without posts?
- Implement a slideshow-like frontpage with text overlays
- Showing “best posts” in front page
- Pull in content from page defined as static front page
- Excluding front_page from is page condition
- Why does my site show the correct front-page when you arrive at the site, but not when you click ‘home’?
- Change Front Page Word Press 4.1
- custom change in front page [closed]
- Remove edit post link from static front page
- WordPress certain directories not connected
- Homepage not working after setting as frontpage
- Hiding New Posts on Front Page
- change header height on 2017 theme for logged in users
- How to connect front-page.php to page in admin panel?
- Can I have two websites with one front page
- How to echo site url if not on index.php while using anchor based nav
- I created a new home page and set it as the home page in the reading section, but I get an error when typing in the home page url
- Categories with post from child categories on front page
- Static front page – going against the grain
- When Front page and Posts page are specified is it possible to just have front-page.php as the home page?
- Custom background for the index page only?
- No posts on front page
- How to display only sticky posts on my automatically generated front page?
- Front page welcome message area
- Static front page as parent of with child pages?
- How did WordPress link an empty page at dashboard to an actual php file?
- Switching MultiSite installation from HTTP to HTTPS
- Getting the Site URL Including the Front Base
- How to add “Stick this post to the front page” to front end?
- What is the correct method for determining ‘is_front_page’ when using filters such as ‘pre_get_posts’ and ‘posts_where’?
- Static page homepage not showing the_content
- Setting a permalink for the home page?
- wp_title() empty on a static front page
- Trying to exclude first 5 posts from the first page on the homepage
- Using add_rewrite_rule() to redirect to Front Page
- Set Default Page On Customizer Live Preview
- Theme’s page.php and index.php template files are confusing me
- Can I hide a specific post from latest posts page?
- Should I use custom post types for a front page video feature (vimeo)?
- Logout redirects to a broken page(home URL is omitted)
- Output shows a page instead of a list of blog postings
- Pagination is somewhat working on frontpage, doesn’t update when “prev” is clicked
- Unable to load WordPress local site after changing WordPress Address (URL) and Site Address (URL)
- Detect if current page is front page within custom query
- Any Ideas for Including “More Tag” with get_pages($args)?
- Is_front_page inside header.php is always returning true
- How to set wp_options in functions.php for removeing the Default Front Page
- Different Front page for Mobile
- What file is the standard frontpage that lists all the posts?
- Extra Text in URL
- Rewrite Rules problem when rule includes homepage slug
- Best Practice for Displaying Categorized Posts on Front Page
- Creating Menu Links in a Custom Theme
- I want to load a pre-built php page (and assocated scripts/styles/directories) as the front page. How do I go about this?
- Gravity Forms Anchor only on Front Page?
- Create a frontpage.php and static page template
- Different URL for homepage then all your other pages
- I need advice on how to structure the categories according to the layout i have
- “Blog pages show at most” in setting not working
- How to show taxonomy on front page
- SSL not working fine, Home url not matching with site url wordpress errors
- one url for all pages
- My question:When I started my website, the “page not found” error always came up
- After Migration From dev, Only my Links to the Homepage Still Redirect to dev
- Redirect to Page after Login (with variable)
- Can I check who updated the static front page on WordPress and the time it was done
- Blog broken after changing Site/Home URL
- Moving Site: Is Re-downloading Files After Changing URLs necessary?
- How to retrive previous Domain URL in Wp
- adsense code showing on random post thumb
- Reverse ordered pagination on home page
- How i can customize WordPress front page in WP dashboard editor?
- WordPress Site says Front Page is 404 When Not Login
- Home page returns 404
- wp_head not injecting css
- Show custom category archive as front page and remove taxonomy slug from urls
- My Website’s Main URL redirects me to an Archive Page