admin管理员组文章数量:1279115
I'm working on a website that is still being built; however, the client would like to launch a landing page while it is being finished. What is the easiest way to make it so all the pages of the site are hidden from view except for the landing page to non-logged in users? (For logged-in users I'd like it to function normally so I can finish building the site.) I'd like the hidden pages to show a simple message or 404 in case someone happens to navigate to one, but nothing else (not the header, footer or menu). I figured there'd be a plugin for this, but alas, that doesn't seem to be the case. Any help is appreciated!
I'm working on a website that is still being built; however, the client would like to launch a landing page while it is being finished. What is the easiest way to make it so all the pages of the site are hidden from view except for the landing page to non-logged in users? (For logged-in users I'd like it to function normally so I can finish building the site.) I'd like the hidden pages to show a simple message or 404 in case someone happens to navigate to one, but nothing else (not the header, footer or menu). I figured there'd be a plugin for this, but alas, that doesn't seem to be the case. Any help is appreciated!
Share Improve this question asked Oct 6, 2021 at 5:35 Psychedelic WizardPsychedelic Wizard 113 bronze badges 2 |1 Answer
Reset to default 1I'd go with a similar approach as @Buttered_Toast:
- Create a template for a specific page (see template hierarchy, especially single page) and set this one as the home page. This then is your "landing page". Do not forget to remove all references to wp_head, wp_footer, etc.
- Add a condition into the header for all other pages/posts that checks for
is_user_logged_in()
and do awp_redirect()
to the home page, if the user is not logged in. This is a nicer solution than a message or a 404, IMHO.
This way you can easily continue working, but the landing page will be there.
Sidenote: I would NOT recommend to develop on a site that is publicly available. All your debug messages will be exposed. Create a development environment (if nothing else, take a subfolder and lock it with htpasswd), develop there, and if you are ready, migrate everything to the production system.
本文标签: user accessHide all pages except landing page
版权声明:本文标题:user access - Hide all pages except landing page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741283550a2370145.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
header.php
that checks for logged in users, if user is not logged in I doget_template_part('some-template')
thendie;
, in the template I create all my code, usually hard coded withoutwp_head()
andwp_footer()
(because this template doesn't contain much code and don't need to load WP resources). – Buttered_Toast Commented Oct 6, 2021 at 6:13