You can check for the single page by using is_single() function.
https://developer.wordpress.org/reference/functions/is_single/
As for index page, I am not 100% sure but is_home() may be the one.
https://codex.wordpress.org/Function_Reference/is_home
Related Posts:
- Template Hierarchy: confused with index.php, front-page.php, home.php
- How to use a specific category archive index as the site front page?
- Overriding default template if page slug and post type are same
- Change Page Template Based on Category
- Load custom template for specific GET parameter
- where is the code that executes the template hierarchy?
- WordPress Page Hierarchy
- How to force sub-product-category to use the parent category template
- How to determine the template loaded when you are not an Admin?
- Template hierarchy override
- How to define the template priority between built-in categories and custom taxonomies?
- What is the difference between the “Main Index Template”(index.php) and HomePage(front-page.php)
- About template hierarchy
- Front-Page.php and Index.php
- Displaying a custom post type and an archive page
- Which page is referring to *all posts by author*?
- Get the current hierarchy php page
- Custom taxonomy query broken after upgrade to 4.4
- CPT Template Not Showing – Getting 404
- Create “File-less” Page Template in Functions.php
- Overide get_template_part( ‘partials/post’, ‘sidebar’ ); with a plugin
- How to make child categories recognize parent’s template displays
- Template for specific post of custom post type
- How can I set up a category “overview” page?
- LOST in WP Template Hireachy
- How to Handle CSS for Multiple Header header.php Files?
- page_template toggle between 2 templates + 2 permalinks for same post
- Static Front Page problem
- index.php template is used instead of blog page
- Single page template for custom post_type
- Trying to manage templates on a blog with lots of custom taxonomies
- is_archive() content being shown instead of is_category()
- How to apply a custom template for posts by default?
- WordPress Template Hierarchy
- Which php file lists all the post of a category
- Displaying all Video Post Formats to Page
- Custom post type and taxonomy permalinks – Structure
- Understanding the WordPress template hierarchy
- Rewrite URL for only archive page (custom post type)
- For custom templates, is it better to use `template_include` or `type_template`?
- Is there any way to get all the name or slug of template parts used in a page?
- Hook to override title, image and content
- Inheritance of parent theme plugin files in a child theme
- Manipulating show_on_front, page_on_front, page_for_posts and template hierarchy
- Category-slug.php not being used
- Custom post type templating problem
- Is there a way to set different post templates for parent posts and child posts in the same post type?
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Single page site with history.js
- How do I create a custom archive page depending on the custom taxonomy type?
- Having trouble with Template hierarchy. I Need to create a set of pages that drill down from states to specific locations
- How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?
- WordPress Doesn’t Generate Taxonomy Archive
- All top-level pages are using index.php as template
- Is there a template file to list all terms of a given custom taxonomy?
- rewrite taxonomy-{taxonomy}-{term}.php terms
- Override Taxonomy Template
- Use one template only for custom post type archives?
- Custom Empty Results page for my Custom Post Type
- get_month_link uses what wordpress template?
- Taxonomy-$taxonomy-$term not working
- Use meta boxes inside an archive page template for Woocommerce
- understanding theme hierarchy
- standard custom page template hierarchy for plugins
- inserting content of 1 Post to in another with a template hierarchy
- Different Loop for tag pages?
- The best way to create pages like an ‘about’, ‘contact’ and etc [closed]
- WordPress sub taxonomy template
- localizing variable on front-page.php template fails but succeeds on single page and taxonomy archive
- Archive-custome_post.php template not working
- How to link to the page displayed by home.php?
- Using index.php as page template
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Help Understanding Template Hierarchy
- Is it possible to set archive.php instead of index.php to display blog?
- Prioritise Pages over Taxonomy Term Root Archive, but not Taxonomy Term Child Archives
- WordPress custom pages in a folder
- User role templates
- Assign template to custom page type?
- BuddyPress : how can I call the template WordPress would have chosen (template hierarchy)?
- How can I make custom page templates work on child theme?
- which template should I use for single category post?
- Specific template for subcategory of custom taxomy
- More than one search results page template for two searches on site
- taxonomy – templates are not loading
- Templates for CPT not working
- Different templates for each category level
- Page has no template
- How to add dynamic content to posts page, archive, taxonomies, search, author, etc?
- Use different file includes for single.php
- Custom Homepage As Single Page or Custom Post Type?
- How to stop the search results from loading the wrong template?
- Needed to change slug to access page
- How to display custom taxonomy
- URL Rewrite Adjustment for Custom Post Type causes template to revert to index.php
- CPT Template Not Showing – Getting 404
- Template files not working for archives and categories
- Custom taxonomy meta fields
- What is the point of using archive.php instead of index.php?
- Unload templates; disable parent Template Parts using only “theme.json”