I managed to get the required result like this:
<?php
$template = get_page_template_slug();
if ($template === 'my-template.php') {
//do stuff
}
?>
Related Posts:
- Jquery Slider for profile template
- if ( is_home() && ! is_front_page() )
- Is including the loop necessary for page.php? [duplicate]
- What is best way passing variables to theme templates and using them different places like widgets?
- Page template not displaying
- Loop through pages with specific template
- How to get_template_part using AJAX?
- wp alchemy multiple image uploader output images to template
- code suddenly appearing from my tempate second loop
- Get search.php results in header.php?
- WordPress Loop inside Loop?
- Template structure
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- Order archive results by post id in custom taxonomy template
- Default ‘post’ post type archive slug?
- How do I make a variable available inside partials?
- 404 Template customization | Want 10 recent Post on the 404.php error page apart from the error Notice
- Second Loop Showing Only One Post on Single Post Page
- How do I put my frontpage featured image in a page template for home.php?
- Get markup for post without loading into the template
- How to render the single post template with the post name?
- excerpt not showing up
- new custom theme – posts displaying on top of one another
- How do i create a list-posts-page?
- How to sort a loop after most viewed
- How to loop specific Category menu from archive page?
- How do I set the Stewart Search Template to return only published posts in the result
- Is it possible to set archive.php instead of index.php to display blog?
- is it bad to copy the loop for a template?
- Is “the loop” a template tag?
- Deeply Nested Menu Loop with Twig using Timber [closed]
- WordPress with woocommerce custom query
- Alternative layout the loop
- Cant pull in featured Image
- Template included with plugin doesn’t return all posts for custom taxonomy
- Creating a archive for taxonomy terms, not the term results
- Secondary loop cuts off at 10 posts?
- Need a conditional to test if title of parent page matches title of child page
- get all page templates
- Load featured article once in a loop
- wordpress showing all posts instead of date range
- How to implement template file and the loop
- Same posts within a paginated page
- How can I create an entirely new, separate display of posts?
- Get date of last update outside of loop
- Pagination adding extra posts only on page 2
- If Loop has odd number of posts on last page Custom style for last post in it
- Custom page template
- Get posts that matches specific terms of multiple custom taxonomies
- How can I use get_permalink() outside the loop?
- Two loops by pre_get_post on same page
- How to check for specific content in comments in the loop
- Problem the_permalink
- Can’t access login screen, wp-login.php 404’s
- Create static front-page with 3-5 recent posts
- get latest 5 posts and a specific post and sort in a specific order
- Pagination for multiple loops
- Infinite Scroll on a loop?
- Post classes in the loop are being changed in certain themes
- “Call to a member function have_posts() on array” error on have_posts();
- Returning One custom taxonomy term name
- How to exclude or filter password protected posts when using next_post_link() previous_post_link
- Get the image src and href data from posts
- Sending mail not working correctly
- Call wp-blog-header.php header without performing a wp_query
- Display post formats differently on index.php (loop in function)
- How to output thumbnail twice in a loop
- Frontpage pagination by week
- Integrating WordPress with Your Website
- Multiple instances of Featured Image Thumbnail As A Background On Homepage
- Altering “posts_per_page” for defaut loop
- Why doesn’t ‘continue’ work in page?
- Accessing the Posts page Content
- Query post & loop problem.
- Exclude current post ID from loop in sidepbar.php
- loop inside a loop : search for posts in the same category
- How do i create a loop that list and divide posts into months?
- the_post() in RSS feed
- Forcing page to top of the list when using get_pages
- Duplicated tag in loop
- Loop only shows first two posts
- Why is my archive page looping through all but one post?
- Loop two different category WP_Query
- Use ACF Category Image for all Taxonomy Archive Views
- Loop with custom posts, to include information from different custom post type
- Transient not working for external data
- adding tax_query to $query_string
- Loop returns more items than exist?
- Remove posts_orderby filter then add it back in
- the_title() Returns the page title instead of the post
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- How does the JSON API work to parse incoming JSON and fetch a post based on an ID?
- How to add excerpt in loop in Twenty Eleven theme?
- Show only posts from todays date [duplicate]
- I need to update the post query? [closed]
- How to create custom page templates with default page layout framework?
- Multiple loop with pagination in same page
- Why did my most recent article fall behind an older one on my site?
- wp_mail function not working in user query loop
- How to set and retrieve cookies while in the loop