Fixed with:
<?php
// For the main <title> tag
add_filter('pre_get_document_title', 'custom_course_cat_main_title', 999);
function custom_course_cat_main_title($title) {
if (is_tax('course_category')) {
$term = get_queried_object();
$custom_title = get_term_meta($term->term_id, '_seopress_titles_title', true);
return !empty($custom_title) ? $custom_title : $title;
}
return $title;
}
// For the SEOPress meta/OG/Twitter titles
add_filter('seopress_titles_title', 'custom_course_cat_seo_title');
function custom_course_cat_seo_title($title) {
if (is_tax('course_category')) {
$term = get_queried_object();
$custom_title = get_term_meta($term->term_id, '_seopress_titles_title', true);
return !empty($custom_title) ? $custom_title : $title;
}
return $title;
}
?>
Hello elaraweb,
Thanks for providing this solution!
We really value your input and will look into the possibility of creating an add-on for LearnPress to tackle this problem, provided it fits our development plans. This would allow for a smoother integration between SEOPress and custom meta titles for course categories.
Once again, we appreciate your insightful feedback!
Best regards,
Brianvu-tp