use the wp_title filter. just remove all your code from header.php and put this into your plugin instead:
add_filter( 'wp_title', 'my_wp_title', 10, 2 );
function my_wp_title( $title, $sep = '|' ) {
if ( is_page( physician_single_pg() ) and get_query_var( 'doctor' ) ) {
$doctor = get_query_var( 'doctor' );
$title = ... // here you put your code to build your title from the doctor & hospital name
}
return $title;
}
add_filter( 'query_vars', 'my_query_vars' );
function my_query_vars( $vars ) {
$vars[] = 'doctor';
return $vars;
}
Related Posts:
- Changing title of a page dynamically from within a plugin
- Change language on website and change currency with url query
- Show a different number of posts per page depending on context (e.g., homepage, search, archive)
- Custom pages with plugin
- Add rewrite rule to permalink structure
- Add Rewrite Rule for custom page
- add_rewrite_rule, plugin activation and plugin deactivation
- Search and replace text across all posts
- Change page title from plugin
- What is the proper filter to add html to a post / page title?
- How to add terms to a post depending on its title?
- Custom rewrite rule is not picked by WordPress
- Add .html extension to custom post type taxonomies
- bulk post_content update
- Woocommerce different URL for every table placed in the restaurant
- Author Specific URL’s in WordPress
- Does flush_rewrite_rules() remove all rules added by other plugins as well as mine?
- Add_rewrite_rule doesn’t add custom url in plugin
- Nested CPT URLs + Posts 2 Posts
- flush_rewrite_rules() not working on plugin activation
- [Plugin: Posts 2 Posts] How does it work?
- custom taxonomy and custom post type url conflict
- Post query – show posts from specified day and month and whole years
- WordPress URL redirect
- Best way to hook a custom url?
- Checking that the Rewrite API is available
- How to Create a Custom Plugin Permalink
- Plugin echos text from shortcode function in gutenberg page editor
- How to append to title via functions.php for auto-posting plugin [duplicate]
- how to change the verification url of pie register plugin of wordpress?
- Custom rewrite rules not working with WPML
- Rewrite rule not matching
- WP Query. Is there a maximum size?
- WordPress and a secondary database?
- Which filter affects the ‘entry-title’ post class
- How to Create a Custom Slug for Tags and Categories with a prefix or suffix?
- how to add text to posts from tags
- URL rewrite of independent plugin?
- Plugin generated taxonomies’ permalinks with custom placeholders
- plugin code is pulling information from database in one instance and not in other. What is wrong?
- Show Sitename on Yoast SEO Title tag [closed]
- correct validate and sql query
- correct sql query
- SQL query, error
- Modify page title and subtitle with a plugin
- Create a post builder skin in a plugin
- Locked out of admin panel after installing HC Custom WP-Admin URL [closed]
- Insert Message before content of after title
- Custom url rewriting
- Taxonomy Drill-Down / Plugin Help – hierarchical queries within plugin?
- WordPress plugin url for form submit
- Creating author Specific page URL
- What is the best way to cache pages on WordPress
- problem with sql query
- add_query_arg not work in admin
- URL rewrite with external JSON query
- How to return the values from a row where a value occurs for the first time among the rows available?
- Site shows URL instead of “meta title” after deleted few plugins (not any SEO plugin was deleted)
- WordPress rewrite rules not working
- How to rewrite URL and get the values?
- How to force load a page in plugin?
- How to embed a new string in url?
- i want to rewrite my custom plugin url
- rewrite file to wordpress
- TranslatePress | secondary language category/sub-category not working correctly “`/%category%/%postname%/“`
- Hidden permalink different from displayed permalink
- Having a problem with rewrite_rules and rewrite_tags – url not rewriting properly and query var missing
- Displaying different content depending on variable
- How to create algorithm for ordering posts in WordPress?
- WordPress rewrite rule depend on meta values not ids
- Custom Rewrite Rule Removing Query String
- one url for all pages
- How To Use htaccess to Rewrite Link Structure for a Page that is Generated Programatcially
- How to give .html extension to just one post not all post
- URL Rewrite 404
- catch urls with specific pattern and show specific content for them by plugin
- How to make the first letter of a post title uppercase, in a plugin?
- I am trying to rewrite urls in WordPress, but its not working
- Multiple Meta key in search
- Get custom term link archive with prefix
- Change default url to plugin custom post type
- Having trouble going from Jfiddle to implementing in WordPress :(
- Custom pages with plugin
- Creating custom URL for async content
- URL RewriteRule doesn’t work when using WP Database Participants in my WordPress website
- How To Rewrite WordPress Pages URL Only?
- custom url with custom post
- How to remove post redirects
- Apache rewrite rules and wordpress problem
- get_var result empty for query of custom table in plugin admin
- URL Rewriting from a Plugin based on custom values
- why the current date do not update
- Plugin with custom domain
- Using wp config to connect to a DB from a plugin
- How to get the real address from a url (permalink)
- Remove base from the custom post type URL [duplicate]
- WP Job Manger change jobs url (NOT slug)
- How can I output completely custom content with plugin while still having header, footer, sidebar etc [closed]
- Please Check this ‘.htaccess’ File
- How to rewrite URL using .htaccess in WordPress Plugin