Site icon Hip-Hop Website Design and Development

Custom function that re-writes page title breaks when the Yoast plugin is activated

I recently had someone here help me write a custom function for the WordPress site that I’m developing so that it re-writes the page title when a 404 error is encountered. It’s been working exactly the way I’d intended — however — it stops working when I activate the Yoast plugin. I don’t get any PHP errors or anything, but my page title simply doesn’t get re-written.

My assumption is that the Yoast plugin likely already hijacks the re-writing of the page titles, and that it is effectively overriding my custom function.

How would I update the custom method below so that it acknowledges the existence of the Yoast plugin, and so that I can leave the plugin active, yet still preserve the functionality of my custom method that re-writes the page titles?

Thanks,

— Yvan

<?php
function theme_slug_filter_wp_title( $title_parts ) {
    global $parsed_address, $api_results, $wp_query;
    if ( ! $parsed_address ) {
        return $title_parts;
    }
    $title_parts['title'] = ucwords( $parsed_address ) . ' | AAA Real Estate';
    return $title_parts;
}
add_filter( 'document_title_parts', 'theme_slug_filter_wp_title' );

?>