• Resolved syncbox

    (@syncbox)


    Is there some way to test if the WP app is using the index.php file for displaying content? I know I can say

    if (is_category())

    or

    if (is_page())

    etc…

    but as far as I know, there is no

    if (is_index())

    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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • is_home

    more: Conditional_Tags

    Thread Starter syncbox

    (@syncbox)

    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.

    Thread Starter syncbox

    (@syncbox)

    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?

    hi syncbox,

    i want the same thing as you. what is your nested solution? or since 8 months have past, have you got another solution?
    thanks,
    Cezar

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘test if WP is displaying with index.php file’ is closed to new replies.