Custom additions to permalinks for any kind of type (archives, posts, root).

Endpoints should be registered on init with:

add_rewrite_endpoint( $name, $places );

Parameters

  • $name – The name for the endpoint, example: api.
  • $places – Where the endpoint should be registered. There are some fixed constants, you should use:
    • EP_NONE – Nowhere. Rather pointless.
    • EP_PERMALINK – Permalinks for singular posts.
    • EP_ATTACHMENT – Attachments.
    • EP_DATE – Date archives
    • EP_YEAR – Year archives
    • EP_MONTH – Month archives
    • EP_DAY – Day archives
    • EP_ROOT – Front page
    • EP_COMMENTS – Comment pages
    • EP_SEARCH – Search results
    • EP_CATEGORIES – Category archives
    • EP_TAGS – Tag archives
    • EP_AUTHORS – Author archives
    • EP_PAGES – Pages
    • EP_ALL – Everywhere

You can combine multiple places with bitwise operators. To add an endpoint to search and author pages:

add_rewrite_endpoint( 'api', EP_SEARCH | EP_AUTHORS );

Make sure to flush the rewrite once with flush_rewrite_rules( FALSE ); after you registered the endpoint.

history | excerpt history