[亲测有效]怎样获取wordpress当前页面分类ID-WordPress主题

摘要:最近大挖在仿一款导航站页的主题,导航的菜单想通过分类ID的锚链接来实现,那这里就需要用到当前分类ID获取功能,通过一些搜…

最近大挖在仿一款导航站页的主题,导航的菜单想通过分类ID的锚链接来实现,那这里就需要用到当前分类ID获取功能,通过一些搜索找到了陌小雨的文章,通过大挖的测试有两个调用方法来是比较好用的,成功的获取到了分类id,但是第三种方法出现了一些错误提示,所以推荐大家可以选用第一种。高效方便。

方法一:在 page单页面使用:

方法二、在主题中添加自定义函数,然后再调用这个函数。

获得当前分类目录 ID:

方法三、通用,分类页和文章页都可以用。

根据大挖的测试,方法一和方法二适用性比较强,方法二的偶发错误。

来源:http://www.wazhuti.com/1733.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_13064.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?