Detect the browsed page from url in wordpress

2019-09-18 09:44发布

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.

Please help me with this.

2条回答
闹够了就滚
2楼-- · 2019-09-18 10:21

Just add a simple:

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

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

查看更多
手持菜刀,她持情操
3楼-- · 2019-09-18 10:22

wp_list_pages function should get you what you're looking for.

查看更多
登录 后发表回答