The is_page_template()
function is for checking if the current page is using a specific custom page template. That being a template selected from the Template dropdown in the Page Attributes box when editing the page.
The WordPress conditional tags are not based around which template files are used. They are used to tell you what content is being viewed, regardless of which template files are present in a theme. For example, is_category()
will return true
when viewing a category archive, even if your theme does not have a category.php
file.
The list of available conditional tags is documented here.
If you want to use Query Monitor to figure out what conditionals to use for what pages, use the Conditionals tab:
Related Posts:
- How to implement a custom sliding banner? [closed]
- To close or not to close php
- How does printf( __( ) ); work?
- Return HTML Template Page with PHP Function
- How to get the custom header image’s alt text?
- Why do templates contain so many PHP tag pairs?
- Is there a way to parse shortcodes in PHP?
- Displaying a WooCommerce product via PHP
- What exactly does “Posts page” do in WordPress?
- Check if a menu is empty?
- Static Frontpage Pagination – Custom loop
- Get the php template file from other theme folder
- WordPress Template Engine?
- How to have a custom display for both woocommerce archive and product-category pages? [closed]
- wp_remote_get returns an error for valid URL
- On this day PHP code
- How to loop over custom fields in a page template?
- Blank on static home page?
- WordPress theme & site not loading after moving files
- Adjust the results quantity for Search Results page pagination
- Exclude pages with certain template from wp_list_pages
- Use Timber/Twig to pull an image by image ID [closed]
- Categories Template Assistance
- Is it possible to use the featured image of a page as a css background without inlining?
- Unable to set right time in admin and frontend template
- Easiest way to show total number of subpages
- Switching between custom templates in a post type of the admin menu
- Use template for posts with a particular category grandparent
- Mysterious HTTP 404 header in my own scripts
- Blank space at beginning of tag?
- Placing the_content inside shortcode not working
- Link to file in plugin directory from wordpress template?
- Password protecting content in custom template
- How to override wp-admin styling
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- How to display user nickname (not display name) in PHP template?
- Custom Template 404 for specific custom post type
- An unwanted inline style is added to my body tag
- How to properly insert a link to a template in WordPress?
- Custom field value not saving when it contains a URL?
- Automatically add custom CSS to new posts using a category template
- Render ninja form inside markup
- How can I load a PHP page without using a Template?
- Changing custom logo link
- From where the header-text can be changed in WordPress custom header?
- how could I load a different template part by page
- creating a second image attachment template?
- Mass update excerpt
- How can I get a single php file that is the equivalent of an existing WordPress page?
- Get and insert order email address to the PHP template inside HTML text
- Custom search results page not working with empty search
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- How to show single category archive
- code is skipping a div
- Issues getting PHP to display in category pages
- Change title only in dynamic page
- Secondary navigation menu on one page
- Enable custom logo upload if logo is not in header
- How can I edit the content in index.php? [duplicate]
- Woocommerce Show Single Product on Homepage
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- how to show only specific category for a template
- Show a different code on front page to other pages
- Does wordpress templates always in files or in database?
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Using same variable names in files added with get_template_part()
- PHP include is only working in certain places in my custom WP theme
- Use WordPress function in php file
- Adding wrapper elements in the_date() like in the_title()?
- How to get all author posts outside of author templates
- Add filter multiple times using only one master function
- Add point on excerpt post
- WooCommerce – Print Processing orders [closed]
- Loop returns more items than exist?
- Access methods in plugin template
- Create dynamic content from one WP page to multiple other pages
- How to call a certain object/menubar in a PHP file
- Adding theme support for a custom header image
- Adding header function to theme
- Problems With Query and/or Template Part and/or PHP
- why is this content-template not showing any of my blog-entries?
- how to register a second page-template
- why is markup routinely placed in functions in wordpress?
- PHP code rendered in HTML
- Odd page behaviour after removing sidebar
- get_permalink returning first letter
- Custom Archive Page
- If I define a variable in header.php, how do I make it available to templates?
- How to refresh a template page on WordPress in 3 seconds – easiest method?
- php “use” not working in template [closed]
- Loop on a wordpress Page instead of content coming from the WP text editor
- Twig+WordPress how to use array arguments inside a function?
- Create custom API endpoint to change custom header image
- How can one use variables in a template or template part without polluting the global scope?
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)
- How to edit templates created in the block editor in code / template files not updating
- WordPress post-template null warnings
- AJAX Appending Data Adds Mystery “0” :(