如何检查当前查看的页面是否是WordPress中的端点?

hen*_*ght 1 php wordpress rewrite endpoints

我已经添加了一个端点来使用作者链接 add_rewrite_endpoint()

我现在可以有以下链接: example.com/author/username/articles

要检查当前查看的页面何时是作者页面(example.com/author/username),我可以这样做:

if ( is_author() )
Run Code Online (Sandbox Code Playgroud)

但是如何检查当前查看的页面是否是我的新端点?即:example.com/author/username/articles

参考:

https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint https://codex.wordpress.org/Function_Reference/is_author

hen*_*ght 7

我找到了答案:

global $wp_query;
isset( $wp_query->query_vars['articles'] )
Run Code Online (Sandbox Code Playgroud)

  • 在某个时刻,你必须写一篇博文:"掌握端点,由亨利·赖特";) (2认同)