What are the different ways to detect home page in wordpress?

后端 未结 7 732
自闭症患者
自闭症患者 2021-02-06 04:59

What are the different ways to detect wordpress homepage

except is_front_page() and is_home()

Thanks

7条回答
  •  逝去的感伤
    2021-02-06 05:43

    is_front_page() is what you want.

    I assume, by the fact that is_home() is not working, that your home page is static, according to the settings in wp-admin.

    is_home() returns true on your main blog page whereas is_front_page() returns true on which ever page is defined as your front page, feed or not.

    From codex:

    This Conditional Tag checks if the main page is a posts or a Page. This is a boolean function, meaning it returns either TRUE or FALSE. It returns TRUE when the main blog page is being displayed and the Settings->Reading->Front page displays is set to "Your latest posts", or when is set to "A static page" and the "Front Page" value is the current Page being displayed.

提交回复
热议问题