I know this question has been asked thousands of times before, but I have attempted a lots of these solutions without any success.
Attempted solutions, among others (added to the template page)
add_filter('the_title','callback_to_set_the_title');
add_filter('wp_title', 'callback_to_set_the_title');
global $title;
$title = 'My Custom Title';
add_filter( 'pre_get_document_title', 'callback_to_set_the_title' );
add_filter( 'document_title_parts', 'callback_to_set_the_title' );
The scenario is that I have a custom template for a job listing page. This page has url rewriting in place that rewrites domain.com/about/careers/search/job?slug=whatever
to domain.com/about/careers/search/job/whatever
- the slug is used to retrieve an entry from Redis that contains all the info for the job listing including the title I'd like to use.
Here's how I am rewriting the URL (from functions.php):
function job_listing_url_rewrite() {
global $wp_rewrite;
add_rewrite_tag('%slug%', '([^&]+)');
add_rewrite_rule('^about/careers/search/job/([a-zA-Z0-9-_]+)/?', 'index.php?page_id=6633&slug=$matches[1]', 'top');
$wp_rewrite->flush_rules(true);
}
add_action('init', 'job_listing_url_rewrite', 10, 0);
from Set page title in WordPress with PHP
No comments:
Post a Comment