最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

feed - What is the best practice to check for pretty permalinks?

programmeradmin1浏览0评论

I develop a plugin and therefore I add new RSS feeds. One feed might look like /?post_type=custom-post-type&custom-taxonomy=tax-1&feed=custom-feed

This works pretty good. But if pretty permalinks are enabled also this url works which will be redirect to the same feed /custom-taxonomy/tax-1/feed/custom-feed.

So far so good. My plugin will list all available feeds for the user. My question what is the best practice to check if pretty permalinks are active and which url version should be displayed?

My idea is to look at $wp_rewrite which permalink_structure is set and decide which version to show. Is there a better way to do it?

I develop a plugin and therefore I add new RSS feeds. One feed might look like http://local.wordpress.dev/?post_type=custom-post-type&custom-taxonomy=tax-1&feed=custom-feed

This works pretty good. But if pretty permalinks are enabled also this url works which will be redirect to the same feed http://local.wordpress.dev/custom-taxonomy/tax-1/feed/custom-feed.

So far so good. My plugin will list all available feeds for the user. My question what is the best practice to check if pretty permalinks are active and which url version should be displayed?

My idea is to look at $wp_rewrite which permalink_structure is set and decide which version to show. Is there a better way to do it?

Share Improve this question edited May 22, 2015 at 18:48 Rarst 100k10 gold badges161 silver badges298 bronze badges asked May 19, 2014 at 17:01 obstschaleobstschale 3124 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 8

The Using Permalinks page on WordPress tells you how to check for the permalink structure:

if ( get_option('permalink_structure') ) { echo 'permalinks enabled'; }

The result will be an empty string if permalinks are default, otherwise you will get the permalink pattern though you should not have to worry much about the permalink details if you use Core functions to generate your links.

发布评论

评论列表(0)

  1. 暂无评论