Can’t edit pages using custom page template
-
I have created a custom page template to limit access to certain pages to users with a particular capability. When I apply this template to a page, I can no longer edit it with Elementor, even when logged in as a user a role that grants the correct capability.
The template code is very simple –
<?php?/*?Template?Name:?my-template-name?*/
namespace?My_Namespace;
if?(current_user_can("read_my_custom_component"))?{
??get_header();
??while?(have_posts()):?
????the_post();
????//get_header();
?????>
????<div?id="primary"?class="content-area">
????????<?php
????????the_content();
?????????>
????</div>
????</body>
????</html>
????<?php?
????endwhile;?>
??</body>
??</html>
??<?php?
}?else?{
??wp_redirect(esc_url(wp_login_url()?.?"?redirect_to="?.?home_url(?$wp->request?)));
}
?>The error I get is “The preview could not be loaded”
I am able to edit pages using this template with the default WordPress editor
All plugins are disabled except Elementor and the one which defines my page template, capability etc. All plugins are on the latest version. No error appears in debug.log. Elementor system info is at https://pastebin.com/basEifwV
Thanks
- You must be logged in to reply to this topic.