Check out this Alternative
<?php
// in the loop:
$template = get_page_template_slug( get_the_ID() );
if (in_array($template,array('home1','home2')) ) ){
// Yep, Do your stuff
}
// anywhere:
$template = get_page_template_slug( $some_post_ID );
if (in_array($template,array('home1','home2')) ) ){
// Yep, Do your stuff
}
?>
Related Posts:
- When is get_template_part() preferable to simply using the template.php files?
- Why (and how?) is get_header() erasing all my stuff?
- Is there a way to create a template that does not have the site styling associated with it?
- Delete post: 2 wp_redirect if pages are different
- require happens out of order
- trying to add custom landing page to Twenty Eleven- can’t get rid of Twenty Eleven header/container? [duplicate]
- Creating Ajax backend for Specialised Page Template? Should admin-ajax.php be used?
- Password protected posts redirects
- Variable use in get_template_part
- Overriding page template using page_template filter
- How can I create an alternative home page?
- Dynamically assign same page template to child page as parent
- What content should go in index.php?
- Assign Page Template Within A Custom Post Type
- How to show a post single post in page template
- How to pass a numeric id to a page template?
- Create a new template for twentytwelve
- Posts archive index pagination in a static page custom query
- What’s the most minimal way in which a page can be hooked into WP?
- is_page_template & is_page in functions.php not working
- get page title, url and excerpt of a page
- Theme’s page.php and index.php template files are confusing me
- Use is_category(), is_tag(), … in functions.php
- Why am I getting syntax error, unexpected ‘endwhile’ (T_ENDWHILE) in this template? [closed]
- How to handle a missing page.php?
- Customize edit.php Pages listing in dashboard to show only pages with a particular template applied?
- Remove all theme CSS & JS from wp_head (but only for 1 page template)
- remove page template from dropdown?
- Export csv and force download in template page
- WPML in custom page templates
- WordPress can’t find IXR_Client
- page.php not displaying content
- Creating a custom archive template that sorts post by date
- Only show content if current page is NOT one of 2 page templates [closed]
- How to make text show up – new page template
- Adding general page content to page templates
- Can I install/embed WordPress on a ‘single page’?
- need help with a user-specific custom page template
- Content pulled from page template instead of editor
- SuperCache for Custom Templates
- Adding the_content() in custom template email
- different style sheet for just one page template
- Best Practice – Customise a WooCommerce+WordPress Templates
- WordPress 3.3.1 Page template not showing in admin area
- wp-cli for Creating page-template
- Want to exclude slider from page.php in header
- changing background color depending on parent page
- Can i forget about the post loop inside the page template?
- Display ACF if parent page has specific template
- WordPress archive index page
- Creating page & post templates without template file
- How to get the current category with custom posts
- Does get_template_part() content gets parsed if it’s not executed?
- Get_template_part seems to be ignoring my template
- How to create a custom WordPress front page
- Function to load correct CSS for Template not working
- Change page template programmatically inside foreach
- Custom Same Page Search
- change top banner content on specific page
- Using custom url parameters in a page
- How can I correctly redirect user to the submitted post and define a template for each new post in WordPress?
- Find php file anywhere in folder and subfolder from template
- different sidebars depending on template (is_page_template is not working)
- WordPress page template to show posts as per category dynamically
- page.php template file render a core gutenberg component programmatically
- How to use the same custom page template to iframe multiple urls with entry of new url entered from backend
- How to display the contents of URL1 when user visits URL2
- How to require specific PHP files for specific templates
- send page ID’s to another template
- Restrict Access to Logged-In Users Page Template
- Is there a universal slug for static homepage?
- Target pages using Woo Commerce single product page template
- Where can I find the declaration of `$_wp_theme_features`?
- What is the best way to manage pages content?
- how to get the title, description, pictures on the page?
- Show all images attached to posts as a gallery page?
- Page Template CSS file not loading
- Custom templates stopped working
- .htaccess help to a beginner
- Decision about page templates for static pages
- Loading custom page template on a one page website
- Special 404 header page
- Custom page Template and Script as a Plugin
- How Does One Create a Global Variable Repository
- Adding pages to the Admin panel
- Setting Custom WordPress “Posts page” AS “Front page”
- Make a custom URL and link to custom Template
- Why do some pages on my site use the previous theme?
- How to move from page template to page template
- Recents posts pulling from different post type
- Template tag for /page/# structure
- Adding page Title in a custom coded page
- Utilizing the template hierarchy while storing page templates in a subdirectory
- Add a title to ACF form from frontend
- How do I create a page template that doesn’t show URL, sidebar, nav menu, footer?
- use another theme for just one page
- Custom page template not working on mobile
- Create Page with Template File from Plugin Folder
- I’m building a WordPress theme and noticed that the 404 page template runs along with the corresponding templates for each page. Any idea why?
- How do I update the SEO information on dynamic pages being generated from template_include?