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?
- What’s the difference between home_url() and site_url()
- When to use is_home() vs is_front_page()?
- Using pre_get_posts on true pages and static front pages
- Switching MultiSite installation from HTTP to HTTPS
- How can I create a “Read More” link using the_excerpt() on a static front page?
- is_front_page() malfunction?
- Getting the Site URL Including the Front Base
- How to add “Stick this post to the front page” to front end?
- How do I fetch the static front page using the REST API?
- Ways to have multiple front-page.php templates that can be swapped out?
- is_front_page only works in theme file, and does not work in functions.php
- Is it possible to use a single custom post as the site front page
- What is the correct method for determining ‘is_front_page’ when using filters such as ‘pre_get_posts’ and ‘posts_where’?
- Category page doesn’t use category.php, instead it redirects to homepage
- How to put custom post types on front page
- How to prevent the default home rewrite to a static page
- Facebook comments box on front page
- Difference between bloginfo(‘home’) and home_url() and site_url()
- Filter front page posts by category
- How does WordPress decide what template to use as frontpage
- Custom query_var causes displaying posts archive on front page
- How do I show sticky posts on a static front page that also contains content?
- Static page homepage not showing the_content
- How to remove “http://” When Echoing URL?
- Setting a permalink for the home page?
- What’s the difference between home_url() and get_home_url() from a developmental point of view?
- How to set ipv6 address as siteurl?
- front-page.php stylesheet
- How to set a custom post type post as static front page?
- Remove WPML’s home_url filter
- index.php not loading in main folder of wordpress
- How to create custom home page via plugin?
- Add Adsense code in index.php
- wordpress Static Page pagination
- Pagination causes error 404 when used with front-page.php
- wp_title() empty on a static front page
- Paginated pages are showing correct content but pagination links are not
- How to show taxonomy meta on frontpage?
- How to check if current static page is frontpage from admin plugin
- Trying to exclude first 5 posts from the first page on the homepage
- Set front page as static page [closed]
- Using add_rewrite_rule() to redirect to Front Page
- Index showing source code
- Add rewrite rule to call front-page.php?
- Preferred Use of home_url()?
- How to display 3 different loops in 3 columns on homepage
- Set Default Page On Customizer Live Preview
- Theme’s page.php and index.php template files are confusing me
- Why does WordPress rely on an fully qualified site_url with a 15-step plan for moving a site?
- Using Multiple Queries of “home_url” vs. Calling a Variable Multiple Times
- Can I hide a specific post from latest posts page?