Is there some way to test if the WP app is using the index.php file for displaying content? I know I can say
but as far as I know, there is no
I know that when no posts exists, WP does not use the category.php file… it uses index.php
1) can I force it to somehow use category.php anyway?
2) if not, can I test whether the index file is being used so that I can conditionally display something in the sidebar?
Your help appreciated!
so, is_home() would mean you are using the index.php file even if your options are setting the start or home page to a Page?
I found a way to get my sidebar to display the right thing anyway with some nested if else logic, but I’ll look into this too! Thank you!
None of the conditionals you were mentioning are looking for “files”! They are looking at what query is executed:
showing the “home” or
showing a category archive or
showing a Page etc.
well, that is what I thought, though typically, if you have a category.php file and the logic says if (is_category())
it IS going to use the category.php file
So is_home() isn’t necessarily going to use index.php file if there is a page.php file AND home (start page) is the Page “home”
So I will stick with the nested logic I came up with yesterday in my sidebar that allows me an “else” for pages and an “else” for everything else. Seems to work just fine.
Thank you though, for taking the time to respond! It’s much appreciated and I’ve learned so much from reading your posts (not just to my questions, but all of them)
if you have a category.php
That’s the keyword here!
The is_category will work even with a theme that has NOT category.php file and is using the archive.php for displaying catgeory listing/archive… even more, if it has only index.php (as the classic) the conditional still works 🙂
Does it make sense?
- The topic ‘test if WP is displaying with index.php file’ is closed to new replies.