How can I use the same page-mypage.php file for different pages, without resorting to page templates?


To re-use the same template for different kinds of pages you can use the template_include filter.

Example given from the docs:

add_filter( 'template_include', 'portfolio_page_template', 99 );

function portfolio_page_template( $template ) {

  if ( is_page( 'portfolio' ) ) {
    $new_template = locate_template( array( 'portfolio-page-template.php' ) );
    if ( !empty( $new_template ) ) {
      return $new_template;

  return $template;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.