I'm looking for an answer for the asked question. The reason is I'd like to omit the need to use is_page_template() in WP ajax calls.

Best regards, Dan.

  • can you add more details. question is not clear . – Lasantha May 12 '18 at 10:03
  • It was clear enough for @Jacob Peattie :) – Daniel May 12 '18 at 10:40
  • so now you have an answer, cheers. I need bit clarification thats why commented. :) – Lasantha May 12 '18 at 10:43

To get the page template of an arbitrary page by ID you can use get_page_template_slug():

// Set $page_id somehow, probably getting it from AJAX request.

$template = get_page_template_slug( $page_id );

if ( $template === 'templates/about.php' ) {
    // Do something.
| improve this answer | |

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.