在wordpress中检测主页有哪些不同的方法? [英] What are the different ways to detect home page in wordpress?

查看:28
本文介绍了在wordpress中检测主页有哪些不同的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检测wordpress主页有哪些不同的方法

除了 is_front_page()is_home()

谢谢

解决方案

is_front_page() 就是你想要的.

我假设,根据 wp-admin 中的设置,is_home() 不起作用,您的主页是静态的.

is_home() 在您的主要博客页面上返回 true,而 is_front_page() 在任何被定义为首页的页面上返回 true,无论是否为 Feed.>

来自法典:

<块引用>

此条件标签检查主页是帖子还是页面.这是一个布尔函数,意味着它返回 TRUE 或 FALSE.当显示主博客页面并且设置->阅读->前页显示设置为您的最新帖子"时,或设置为静态页面"且前页"值为正在显示的当前页面.

What are the different ways to detect wordpress homepage

except is_front_page() and is_home()

Thanks

解决方案

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.

这篇关于在wordpress中检测主页有哪些不同的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆