The tutorial is outdated and it seems it missed to flush the rules.
function add_rewrite_rule_and_tag() {
global $wp_rewrite;
add_rewrite_rule( '^physician-profile/([^/]*)/?', 'physician-profile?lastName=$matches[1]', 'top' );
add_rewrite_tag( '%lastName%','([^&]+)' );
if ( ! isset( $wp_rewrite->rules['^physician-profile/([^/]*)/?'] ) )
$wp_rewrite->flush_rules();
return;
}
add_action( 'init', 'add_rewrite_rule_and_tag', 99 );
You can access the query var `lastName´ with
gloabl $wp_query;
$lastName = $wp_query->query_vars['lastName'];
Related Posts:
- How does WordPress handle permalinks?
- URL rewrite based on a custom field value
- Subdomains to pages
- Passing variables through permalink structure
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- Random Alphanumeric Key URLs
- Using WP rather than .htaccess to redirect pages/posts
- How can I add a page’s ID to its permalink using WP_Rewrite?
- Add prefix to page URL based on the page template
- Redirect a Blogger Page URL to wordpress
- Test site pages go to main site
- Redirect From Url To Url
- Redirecting “wrong” but working links to their canonical URL in order to prevent search engine penalties (e.g. /123/ at the end of URLs)
- How are WordPress Page URLs affected by permalink settings?
- Custom permalink structure with %postname% in front of domain name
- Subdomains pointing to a permalink URL
- corrupted URLs – can’t leave starting page
- remove SLASH on single_post but KEEP on categories and parent pages
- Change all pages permalinks instead of hierarchical to have id of the page
- All pages lead to home
- WordPress permalink still not working (error or not understood?)
- My wordpress site must be being affected by outside sources [duplicate]
- Removing /wp in Permalink URL of subdomain led to inaccessibility to WP Dashboard
- Is it possible to get a page link from its slug?
- Need help with add_rewrite_rule
- remove “index.php” from permalinks
- How do I add /blog/ as a prefix to permalink structure for blog posts, tag pages, etc.?
- Passing and retrieving query vars in wordpress
- Permalink format: singular or plural
- Pretty permalinks for search results with extra query var
- How to get pretty URLs with add_query_arg in permalinks
- Creating custom permalink structure for languages
- Custom post type permalink endpoint
- How can I reverse engineer a Permalink to Find the Page?
- How to remove dates from existing permalinks?
- Getting the Site URL Including the Front Base
- Using $_GET variables in the URL?
- Removing the redirect after changing a page’s slug
- Including category-base in a post permalink results in 404
- How can I store page ID in a post instead of other selected permalink?
- WordPress thinks my custom route is a 404
- Page begins with number, WordPress adds 2
- Date based URLs for custom posts and pagination
- Removing hierarchical pages in the permalink
- How to add a custom URL placeholder to author archives?
- 301 Redirects for Changed Permalink Structure & Category Base
- How to custom change author base without $this->front?
- Can WordPress realistically handle a site with 500 ‘pages’?
- Update URL Snippet to Canonical Permalink URL
- How to prevent the default home rewrite to a static page
- How can I force WordPress to redirect to canonical permalinks?
- How do I turn off 301 redirecting posts (not canonical)?
- “.#[random-char-string]” being inserted at end of URLs
- Redirect old permalinks to new permalinks
- + Character in permalink
- How to change author base without front
- permastruct for custom post type not working in one of four cases
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Broken wordpress permalinks on pages only
- Pretty Permalinks
- Make post slug have priority over category slug
- Remove parent slug for child pages
- How to create a permalink structure for posts in a specific category
- How to get a page url by a page id?
- How can I include a query string with get_permalink
- How to remove the index.php in the url?
- How to Remove Slug From Database?
- Permalink redirection from ‘Day and name’ to ‘Post name’
- How to map permalinks with accented letters to sanitized slugs?
- Remove subfolders from URL
- Remove parent slug for child pages
- Nicest way to 301 Redirect traffic when changing permalink settings
- Add custom directory in URL
- Using two permalinks for one post
- flexible rewrite ‘ramble’ URLs with WordPress
- Changing pemalink structure to /%post_id%/%postname%/
- How can I Rewrite a ‘page’ URL based on query string parameters?
- Custom rewrite rules for a $_GET request
- Nice RSS Feed URLs for each custom post type
- htaccess or redirect to cloak portion of a link?
- Change the custom post type permalink
- Redirect short-form URL to long-form URL (post_id to post_id + post_name)
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- custom naming of search permalink /search/
- Relative or Absolute Paths for Flash Video Player Files
- Put post ID on the custom post type URL
- Rewrite url / permalink for default archive – yearly / monthly
- Should I use relative or absolute urls when pointing to internal pages
- How to change the permalink structure of a master page?
- Rewrite user profile URL to be human friendly
- WordPress on VirtualBox – no pretty permalinks
- Stop redirecting to posts not in a category / duplicate slugs
- WordPress 3.4 Permalinks Redirection Problem
- Why I can’t change the permalink of this page?
- Redirect old permalinks with Month and name to Post name on new site
- Permalinks, Rewrites, Get Variables, Oh My!
- Rewrite-Rules not working on a vhost, everything goes to index.php
- WordPress removes spaces in URL on pagination
- Change permalink for a single post entry
- Does WordPress send a 301 header message when you change permalink structures?