This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Hey there! So, you’re diving into WordPress hooks, huh? Let’s talk about the embed_site_title_html filter. This hook allows you to filter the site title HTML in the embed footer. It’s super handy when you want to tweak how the site title appears in embeds.
To use the embed_site_title_html filter, you first need to register it using add_filter
. You can add this code to the functions.php
of your active theme or create a custom WordPress plugin. Personally, I always recommend creating a custom plugin to avoid any issues when you update your theme.
In the examples below, we’ll define a function called weplugins_modify_embed_site_title_html_defaults
which takes one parameter. We’ll register it using add_filter
. The first parameter is the hook name, the second is the function name, the third is the priority, and the last is the number of arguments (if any) to be passed to the function.
Sometimes, you might need to remove a registered hook. For that, you can use remove_filter
to remove the embed_site_title_html filter.
Parameters
Below is the one parameter required to use this hook:
- $site_title: (string) The site title HTML.
Live Examples
Example 1: Basic Usage of embed_site_title_html Filter
Here’s a simple example to get you started with the embed_site_title_html filter.
function weplugins_modify_embed_site_title_html_defaults($site_title) { // Update the $site_title variable according to your website requirements and return this variable return $site_title; } // Add the filter add_filter("embed_site_title_html", "weplugins_modify_embed_site_title_html_defaults", 10, 1);
Example 2: Conditional Modification
In this example, we’ll modify the site title based on a condition.
function weplugins_modify_embed_site_title_html_conditionally($site_title) { if (is_home()) { $site_title .= ' - Welcome to Our Site!'; } return $site_title; } // Add the filter with conditional logic add_filter("embed_site_title_html", "weplugins_modify_embed_site_title_html_conditionally", 10, 1);
Example 3: Removing the Hook
If you need to remove the hook callback, use the example below.
// Remove the filter remove_filter("embed_site_title_html", "weplugins_modify_embed_site_title_html_defaults", 10, 1);
Make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.
Contact Us
If you’re having any trouble using this hook or need some customization, feel free to contact us. We’re here to help!
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.