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]
- Pretty permalinks for search results with extra query var
- Using $_GET variables in the URL?
- Including category-base in a post permalink results in 404
- Update URL Snippet to Canonical Permalink URL
- How do I turn off 301 redirecting posts (not canonical)?
- “.#[random-char-string]” being inserted at end of URLs
- Broken wordpress permalinks on pages only
- Pretty Permalinks
- How can I include a query string with get_permalink
- How can I Rewrite a ‘page’ URL based on query string parameters?
- custom naming of search permalink /search/
- Rewrite-Rules not working on a vhost, everything goes to index.php
- Rewrite URL for results of a custom WP_Query
- custom permalink/shortlink with base62 encoded post ID
- Change permalinks with ACF values
- template_include not loading -instead goes to index.php
- I need a custom permalink for my website
- Need Help Correct Regular Expression Redirect Code
- Making a custom help center page
- Add custom post type name in term link?
- add_rewrite_rule not working for me
- Using WP Rewrite, but just not “getting it”
- Force wordpress to display page with same url structure as categories
- List / Get post redirects
- Redirect /%year%/%monthnum%/%day%/%postname% [closed]
- Rewrite CPT permalinks and include WPML language
- How can I get this custom post type permalink structure? %custom_post_type%-%taxonomy%-%term-postname%
- get_permalink returning site home url instead of the url of slug being passed
- Host frontpage via example.com and everything else via example.com/blog
- 301 Redirect for Non-Date Based URL’s
- WordPress is suppressing page extensions!
- Permalinks only for posts
- Permalinks settings
- mod-rewrite exception? keep #hash in matching urls?
- Edit permalink for certain pages
- Visiting posts results in 404 errors after host migration
- Comment author url link is wrong? How to change from authors/ to author/
- Strange behavior with a redirect loop – involves WPML multi-language plugin
- Getting an ID from a URL, why can WP do this itself, but none of of the functions provided get it right?
- Configuring Home Page Address
- Pagination url for page template
- How can I set up a secondary permalink structure?
- How to force load a page in plugin?
- WP-e-commerce (getshopped) – Annoying permalink issue [closed]
- How to Use metada Value in Url and is it possible? [duplicate]
- How do I rewrite attachment urls when permalink structure contains %category%?
- IIS7.5 URL rewrite pboblem on index page
- Custom child page permalink
- Safest way to create a custom permalink
- How do I structure my permalinks in WordPress?
- Creating an alternate path for a page
- How to change URL from /%postname%/ to custom-name/%category%/%year%/%monthnum%/%day%/%postname%/
- Create different permalinks for same post
- WordPress Attachment Page URL Rewrite!
- Redirect old /%category%/%postname%/ to just /%postname%/
- why wordpress keeps redirecting to old page after deleting it?
- WordPress Multisite ABSPATH and get_home_path() to check for htaccess or web.config file
- Flushing rewrite rules enables to see an article, but I didnt change anything
- Redirect page to homepage, keeping URL
- How can I put WordPress in a directory but keep just the home page at the domain root?
- Permalink structure /page/page/cpt-post gives 404 with pagination
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- Rewrite posts url as they’re all children of a page
- Multiple Permalink Patterns for one page
- The permalink for the page doesn’t work and page’s defined link throws “Object not found!”
- Posts in Page – How to customize the URL?
- Select page/template from the permalink url
- Permalink for pages
- Removed and Reinstalled WordPress, Redirect Broken now
- Pagination is not working, how to trace it properly?
- Why are all pages redirecting to homepage when using custom permalinks?
- .htaccess regex for redirect subdomain to root domain & redirect old permalinks
- how to create several url aliases for a page
- Single product link in woocomerce
- URL issues with WordPress
- Add additional URL variations for a Post
- Blog posts are not appearing as subs of Blog Page
- How to make my custom permalink pull up the correct post