php - Wordpress: for 100 pages site, use 100 page templates or 1 with include functions? -


i'm using different page templates pages create in wordpress. i'm using wordpress intranet portal company. pages, build, need different php code.

what correct way 100 pages site? create pages own page template, , put themes/.../page-templates or create 1 page with:

<?php  switch($current_page_name) {    case "about-us"; include(site_url('/pages/about-us.php'));    break;    case "contact-form"; include(site_url('/pages/contact-form.php'));    break; } ?> 

but how can $current_page_name variable? example have page: http://192.168.210.140/sales-funnel/todolist/ think, there need be:

case "sales-funnel/todolist/"; 

is correct, create themes\twentyten\page-templates\one-column.php:

<?php /**  * template name: main template one-column  */  add_action('template_redirect','my_redirect');          function my_redirect(){             get_header();             echo '             <div id="container" class="one-column">             <div id="content" role="main">               ';             global $wp; //global $wp object return request             global $wpdb;             echo $wp->request;             switch($wp->request) {                   case "sales-funnel/todolist":                  status_header( 200 );                    include (templatepath . '/pages/sf/todolist.php');                  break;                  case "sales-funnel/add-deal":                  status_header( 200 );                    include (templatepath . '/pages/sf/add-deal.php');                  break;             }             echo '             </div><!-- #content -->             </div><!-- #container -->             ';             get_footer();                 exit;         }         my_redirect() ?> 

and use example 50 pages, add case statement file?

you can use template_redirect hook:

 add_action('template_redirect','my_redirect');          function my_redirect(){             global $wp; //global $wp object return request              switch($wp->request) {                   case "sales-funnel/todolist":                  status_header( 200 );                    include (templatepath . '/my-page-template.php');                  break;                  // todo add more cases here             }                 exit;         } 

if want change title of each page can use wp_title filter well.


Comments

Popular posts from this blog

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -