wordpress if is not page template

  1. Open the theme's folder in your WordPress installation directory.
  2. Locate the "page.php" file within the theme folder.
  3. Duplicate the "page.php" file and rename the duplicate as "template-custom.php" (replace "custom" with your desired template name).
  4. Open the "template-custom.php" file in a code editor.
  5. Locate the following code within the file:
<?php
  if (have_posts()) :
    while (have_posts()) : the_post();
      // The content of the page
    endwhile;
  endif;
?>
  1. Replace the existing code with:
<?php
  /*
   * Template Name: Custom Template
   * Template Post Type: page
   */

  // Your custom template content here
?>
  1. Save the changes to the "template-custom.php" file.
  2. Go to your WordPress admin dashboard.
  3. Create or edit a page where you want to apply the custom template.
  4. In the Page Attributes meta box, you should now see a "Template" dropdown.
  5. Select "Custom Template" (or the name you used) from the dropdown.
  6. Update or publish the page to apply the custom template.

Note: Ensure that you have a backup of your theme files before making any changes.