You can use add_feed( $url, $callback )
. Despite its name it sends a text/html
Content-Type.
Basic example:
add_action( 'init', 'wpse_50841_register_extra_page' );
function wpse_50841_register_extra_page()
{
add_feed( 'wpse50841', 'wpse_50841_callback' );
}
function wpse_50841_callback()
{
print '<p>It works!</p>';
}
Visit the permalink settings page once to refresh the rewrite cache, and go to example.com/wpse50841/
or example.com/?feed=wpse50841
to see your code in action.
Related Posts:
- How do you create a “virtual” page in WordPress
- Multiple endpoints to same page
- How to make a category page the blog home page?
- Preserving $_GET parameter while using custom Rewrite Rule
- Handle category name URL rewrite before different post type slugs
- Taxonomy rewrite question
- how to add prefix to post url structor only
- Rewrite rules in .htaccess get overwritten?
- Getting add_rewrite_rule and add_rewrite_tag to work
- Why did installing wordpress in url root jack up underlying WP sites?
- How do I create a dynamic page?
- Dynamic URL, not a physical page within the database
- Passing & Reading URL Parameters with URL re-writing
- Prevent WordPress from automatically correcting URLs
- add_rewrite_rule and pagination issue
- Display content according to current URL
- Nginx rewrite rule conflict with WordPress permalinks rule
- External/non-WP rewrite rule without QSA
- How to do Basic URL Rewrite Without Redirecting
- URL Rewrite doesn’t work for nested pages
- Using custom mod_rewrite without breaking wordpress permalinks
- WordPress Redirects When a Query String Contains a Number
- How does WordPress determine if a paged query var is too high?
- How to remove parent section from attachment URL?
- Pass a comment id through url and append the comment post’s slug in the url
- How to change the main site url on a multisite installation (network)?
- Problem with add_rewrite_rule
- add_rewrite_rule ignoring other params than the “p” param
- optimize wordpress rewrite rule regex
- How to catch Rewrite rules then display a specific post?
- Adding two rewrite rules
- Load an url with minimal/no DB queries
- Login page is redirecting to homepage
- .htaccess rewrite
- Auto generate rewrite rules for multiple taxonomies
- Generating a Rewrite Rule for sSecific Post-Requests from a Submitted Form?
- Change htaccess to redirect to index.php in subfolder
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- URL Rewriting for PHP script on an image URL
- rewrite url for authors
- How to redirect specific URL to Subdomain
- How to rewrite wordpress urls with index.php in them
- Force search form to go to clean url without multiple redirects
- Rewrite query string to path
- map multiple URLs to display home page without changing URL displayed in browser’s location bar
- WordPress Autocorrect URL / Slugs Does Not Work
- Rewrite API -Adding a parameter before the slug
- Rewrite URL based on home_url
- Replace term archives with static pages
- Why does my URL rewriting only work using two different methods?
- Using a custom 410 page
- IIRF + IIS 6 + WordPress does not return 404 error
- Rewrite vs Redirect from ?p={ID}
- Is it possible to set the same base for categories and tags?
- Adding a rewrite rule to page that has no fixed variables and pagination
- Flush rewrite rules on option update with Settings API
- Integer based rewrite isn’t recognized for value of 1
- Re-directing URLs with dates to URLs without dates
- Having WordPress control only certain pages with .htaccess?
- wordpress url correction
- Help with a custom rewrite
- My bbPress rewrite rules aren’t working
- Not able to rewrite the pagination URL for the posts
- add_rewrite_tag works for some parameters but does not for others
- Rewrite specific action url
- Using URL rewrite to add custom URL for custom post type
- 301 Rewriting htaccess
- Using page as front page, why does /page/### work?
- Rewrite rule shows 404 page
- How to transform multiple parameter URL to clean URL
- Exclude subfolder in WordPress permalink
- wordpress path generation from rewrite rule
- How to add dot(“.”) in post slug
- Rewrite WordPress Url from root to subfolder without moving files
- WordPress pagination broken for page 2,3 with custom permalink. Redirects to baseurl
- Rewrite rule for custom permalink structure
- Help with .htaccess setup to hide WordPress Directory
- Ugly URLs when there’s pagination
- Unable to access the query variables in the template
- Hide wordpress source code
- Why is there a 404 on page 2+ for my search page?
- Custom rewrite from URL to URL using slug
- URL duplicating after migrating domain
- URL rewrite before template_redirect called
- Properly maintaining an old rewrite structure
- Custom Post type and Custom taxonomy with URL rewrite worked but template did not
- Add dynamic url with external page in WordPress
- .htaccess RewriteBase equivalent for WordPress – Passing a URL as a variable without getting a 404
- URL Rewrite for CPT single posts
- Using 2 URL’s for WordPress
- Rewriting WordPress URLs
- Need Help With A Rewrite Issue
- Function to rewrite URl in WordPress
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- Can’t get pretty permalinks to work without index.php
- How to rename the WordPress wp-login.php running on IIS6?
- get parameter from url rewrite [closed]
- Generated URLs don’t reflect accurate URLs.
- Change the slug ( url ) to a sequence number starting from 0 in the custom record type?
- Change url site.it/wordpress