I want to change template for all child page of news page.
For this I have write below code in functions.php
function switch_corporate_child_service_page_template() {
global $post;
if (is_page())
{
// Checks if page is parent, if yes, return
if ($post->post_parent == 0)
return true;
else if ($post->post_parent == '20064') // "20064" is "News" page id.
{
$template = TEMPLATEPATH . "/page-corporate_services.php";
if (file_exists($template)) {
load_template($template);
exit;
}
}
}
}
add_action('template_redirect','switch_corporate_child_service_page_template');
For this I have write below code in functions.php
function switch_corporate_child_service_page_template() {
global $post;
if (is_page())
{
// Checks if page is parent, if yes, return
if ($post->post_parent == 0)
return true;
else if ($post->post_parent == '20064') // "20064" is "News" page id.
{
$template = TEMPLATEPATH . "/page-corporate_services.php";
if (file_exists($template)) {
load_template($template);
exit;
}
}
}
}
add_action('template_redirect','switch_corporate_child_service_page_template');
No comments:
Post a Comment