---
title: Filter the_title with SEOPress dynamic variables
url: "https://www.seopress.org/support/hooks/filter-the_title-with-seopress-dynamic-variables/"
lang: en-US
updated: 2021-09-30
hook_name: the_title
---

# Filter the_title with SEOPress dynamic variables

- **Hook name:** `the_title`

```php
<?php
function sp_filter_the_title_dynamic_variables( $title ) {
	$variables = apply_filters( 'seopress_dyn_variables_fn', null );

	if ( empty( $variables['seopress_titles_template_variables_array'] ) || empty( $variables['seopress_titles_template_replace_array'] ) ) {
		return $title;
	}

	return str_replace(
		$variables['seopress_titles_template_variables_array'],
		$variables['seopress_titles_template_replace_array'],
		$title
	);
}
add_filter( 'the_title', 'sp_filter_the_title_dynamic_variables' );
```

Source: [https://gist.github.com/wp-seopress/19272d47eb98abdf90429d7fb6e3aa03](https://gist.github.com/wp-seopress/19272d47eb98abdf90429d7fb6e3aa03)



