WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Drupal, you can assign a URI to a function that gets called, like this:

function mymodule_menu() {
    return array(
        'custom_uri' => array(
            'page callback' => 'my_custom_function',

This then tells Drupal to call the function my_custom_function whenever the url is http://www.mysite.com/custom_uri.

In Wordpress I'm trying to accomplish the same idea. I want to have a custom URI that somehow calls a function to render output.

From what I've found I can use WP_Rewrite to turn a permalink into a query string and then check for the query string in my plugin. Going that route, how would I display my own content in the site's theme?

The other option I've seen is to do it via a shortcode, but then that means either the user generates a page or I do it programmatically (and then probably use WP_Rewrite to set up a custom permalink). This seems messy and I'd rather the user not have to worry about doing any work.

Are there any more options?

share|improve this question
up vote 2 down vote accepted

Create an endpoint. That is a custom URL that will be handled by a callback.

Examples are How can I use WordPress functions in my stylesheet? and Is it possible to request several post types from a feed?. See also add_rewrite_endpoint() and A (Mostly) Complete Guide to the WordPress Rewrite API.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.