从WordPress中的URL检测浏览的页面 [英] Detect the browsed page from url in wordpress

查看:69
本文介绍了从WordPress中的URL检测浏览的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过jquery在首页中的帖子标题下划线和斜体了.我已经在页脚中编写了jQuery代码.页眉和页脚在所有内部页和主页中也通常被称为.因此,当我单击主页中的帖子标题时,将浏览单个帖子页面,但仍然可以看到与首页中相同的帖子标题样式.我需要通过url检测页面,因为我已在管理面板中将url模式设置为%post_name%.此外,我必须设置一个条件来检测页面.如果是主页,则必须启用代码,否则就什么都不用.

I have underlined and italicized the post titles in homepage via jquery. I have written the jquery code in footer. The header and footer are commonly called in all inside pages and homepage as well. So when I click on the post titles in the homepage, the single post page is browsed but I can still see the same style for the post title like in the homepage. I need to detect the page through url as i have set the url pattern to %post_name% in the admin panel. Moreover I have to place a condition to detect the pages. If it is the homepage I have to enable the code else nothing.

请帮助我.

推荐答案

只需添加一个简单的内容:

Just add a simple:

if (is_front_page()) { do this }
else { do that }

有关条件wordpress标签的更多信息: http://codex.wordpress.org/Conditional_Tags

A little bit more about conditional wordpress tags: http://codex.wordpress.org/Conditional_Tags

这篇关于从WordPress中的URL检测浏览的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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