Skip to navigation
List of Yoast SEO filter hooks
21.03.26
Here's a comprehensive list of Yoast SEO filter hooks that are commonly used for customization. Keep in mind that Yoast SEO's internal structure and available hooks can change with updates, so it's always a good idea to consult the official Yoast SEO documentation for the most up-to-date information. **General Meta Data Filters:** * **`wpseo_title`:** Filters the entire title tag output. This is the most common filter for modifying the title. * **Parameters:** `$title` (string) - The current title. * **`wpseo_metadesc`:** Filters the meta description. * **Parameters:** `$metadesc` (string) - The current meta description. * **`wpseo_canonical`:** Filters the canonical URL. * **Parameters:** `$canonical` (string) - The current canonical URL. * **`wpseo_opengraph_title`:** Filters the Open Graph title (for social sharing). * **Parameters:** `$og_title` (string) - The current Open Graph title. * **`wpseo_opengraph_desc`:** Filters the Open Graph description. * **Parameters:** `$og_desc` (string) - The current Open Graph description. * **`wpseo_opengraph_image`:** Filters the Open Graph image URL. * **Parameters:** `$og_image` (string) - The current Open Graph image URL. * **`wpseo_opengraph_url`:** Filters the Open Graph URL. * **Parameters:** `$og_url` (string) - The current Open Graph URL. * **`wpseo_twitter_title`:** Filters the Twitter title. * **Parameters:** `$twitter_title` (string) - The current Twitter title. * **`wpseo_twitter_description`:** Filters the Twitter description. * **Parameters:** `$twitter_description` (string) - The current Twitter description. * **`wpseo_twitter_image`:** Filters the Twitter image URL. * **Parameters:** `$twitter_image` (string) - The current Twitter image URL. * **`wpseo_robots`:** Filters the robots meta tag content (e.g., `index`, `follow`, `noindex`, `nofollow`). * **Parameters:** `$robots` (string) - The current robots meta tag content. * **`wpseo_schema_graph`:** Filters the entire Schema.org graph output. This is a powerful filter for adding or modifying structured data. * **Parameters:** `$schema` (array) - The array representing the Schema graph. **Sitemap Filters:** * **`wpseo_sitemap_index_content`:** Filters the content of the sitemap index file. * **Parameters:** `$sitemap_index` (string) - The XML content of the sitemap index. * **`wpseo_sitemap_{$sitemap}`:** Filters the content of a specific sitemap (e.g., `wpseo_sitemap_post`, `wpseo_sitemap_page`, `wpseo_sitemap_category`). The `{$sitemap}` part is replaced with the sitemap name. * **Parameters:** `$sitemap` (string) - The XML content of the sitemap. * **`wpseo_sitemap_urlimages`:** Filters the images included in a sitemap entry. * **Parameters:** `$images` (array) - An array of image URLs. * **Parameters:** `$post_id` (int) - The ID of the post/page. **Breadcrumb Filters:** * **`wpseo_breadcrumb_links`:** Filters the array of breadcrumb links. * **Parameters:** `$links` (array) - An array of breadcrumb link arrays. Each link array typically has keys like `url` and `text`. * **`wpseo_breadcrumb_output`:** Filters the entire breadcrumb HTML output. * **Parameters:** `$output` (string) - The HTML string of the breadcrumb. **Advanced Filters:** * **`wpseo_premium_post_redirect_slug_change_url`:** Filters the redirect URL when a post's slug changes (Yoast SEO Premium). * **Parameters:** `$url` (string) - The redirect URL. * **Parameters:** `$post_id` (int) - The ID of the post. * **`wpseo_robots_txt`:** Filters the content of the `robots.txt` file. * **Parameters:** `$output` (string) - The content of the `robots.txt` file. * **`wpseo_json_ld_output_by_id`:** Filters a specific JSON-LD schema block by its ID. * **Parameters:** `$data` (array) - The JSON-LD data. * **Parameters:** `$id` (string) - The ID of the schema block. * **`wpseo_previously_used_keywords`:** Filters the list of previously used keywords. * **Parameters:** `$keywords` (array) - An array of previously used keywords. * **`wpseo_breadcrumb_single_link`:** Filters a single breadcrumb link array. * **Parameters:** `$link_output` (array) - The array containing the link data. **Important Notes:** * **Context is Key:** The specific parameters and behavior of these filters can vary depending on the context (e.g., the page type, the Yoast SEO settings). * **Yoast SEO Updates:** Yoast SEO is actively developed, and the available hooks may change in future versions. Always consult the official documentation for the most accurate information. * **Priority:** When using `add_filter()`, pay attention to the `$priority` argument. This determines the order in which your filter function is executed relative to other filters on the same hook. * **Number of Arguments:** Make sure the `$accepted_args` argument in `add_filter()` matches the number of parameters your filter function expects. * **Debugging:** Use `error_log()` or a debugging tool to inspect the values of the parameters passed to your filter functions. This can help you understand how the filters work and troubleshoot any issues. * **Premium Features:** Some filters might only be available in the premium version of Yoast SEO. **How to Find More Hooks (If Needed):** 1. **Yoast SEO Documentation:** The official Yoast SEO documentation is the best place to start. Search for "developer documentation" or "hooks" on the Yoast SEO website. 2. **Code Search:** If you're comfortable with PHP, you can search the Yoast SEO plugin's code for `apply_filters()` calls. This will show you all the places where filters are used. You can use a code editor or IDE to search the plugin's files. Look in the `wp-content/plugins/wordpress-seo` directory. **Example Usage (wpseo_title):** ```php function my_custom_yoast_title( $title ) { if ( is_singular( 'product' ) ) { $title = 'Product: ' . get_the_title(); } return $title; } add_filter( 'wpseo_title', 'my_custom_yoast_title' ); ```
https://developer.yoast.com/customization/news-seo/hooks/
Reply
Anonymous
Information Epoch 1781225210
When in doubt, use brute force.
Home
Notebook
Contact us