Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Call a page from the theme directly
#1
Hi,

how, in my php code, I can call a page directly (without using the admin page control panel) ?
ie: have a page in my theme : under-construction.php but when I calll it (somewhere else in my code) like this :

PHP Code:
<a href="<?php get_theme_url(); ?>/under-construction.php">Consulting</a

I get "you cannot load this page directly." which is normal and what I can expect but how to load it 'normally' like if I use it thru a page ? is there any way ?

thanks in advance,
Domi.
Reply
#2
The solution I have found :

1) create a page "under-construction" with status private and template "under-construction.php"
2) call it like this :

PHP Code:
<a href="<?php get_site_url(); ?>index.php?id=under-construction">Consulting</a


is there another simpler solution and without creating a page ?

Domi.
Reply
#3
(2020-06-14, 18:30:49)Domi Wrote:
PHP Code:
<a href="<?php get_theme_url(); ?>/under-construction.php">Consulting</a

I get "you cannot load this page directly." which is normal and what I can expect but how to load it 'normally' like if I use it thru a page ? is there any way ?

You can access the file directly, this should not be a problem, but your code will be executed outside of the GS concept and you will not be able to use the GS functions. IN_GS is a GS constant which is not set in this case. Delete all GS functions from the file and call it again. Remove this:
if(!defined('IN_GS')){ die('you cannot load this page directly.'); }
Reply




Users browsing this thread: 2 Guest(s)