TODO: To change the header's content go to Dr.Explain menu Options : Project Settings : HTML (CHM) Export : Setup HTML Template and Layout
×
Menu
Index

Điều hướng template

 
Điều hướng template mặc định sang trang khác hoặc một địa chỉ ngoài, bạn sử dụng hook 'template_redirect'.
function my_page_template_redirect()
{
    if( some_condition() )
    {
        wp_redirect( site_url( 'other-page' ) );
        exit();
    }
}
add_action( 'template_redirect', 'my_page_template_redirect' );
 
Khác với template_redirect, bạn muốn thay đổi chuyển hướng sang sử dụng template khác, nhưng vẫn sử dụng nội dung trang hiện tại, để làm điều này chúng ta sử dụng hook 'template_include'.
add_filter( 'template_include', 'my_callback' );
 
function my_callback( $original_template ) {
  if ( some_condition() ) {
    return locate_template('some-custom-file.php');
  } else {
    return $original_template;
  }
}
Made with help of Dr.Explain

Unregistered version